﻿using System;
using System;
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Text;
using netDxf;
using netDxf.Blocks;
using netDxf.Collections;
using netDxf.Entities;
using netDxf.Header;
using netDxf.Objects;
using netDxf.Tables;
using netDxf.Units;
using Attribute = netDxf.Entities.Attribute;
using Image = netDxf.Entities.Image;
using Point = netDxf.Entities.Point;
using Trace = netDxf.Entities.Trace;
using System.Threading;

namespace TestDxfDocument
{

    class _Counterboreswithindexableinsertsanddetachablepilots
    {
        public static void Counterboreswithindexableinsertsanddetachablepilots(Dictionary<string, Object> data)//细柄丝锥
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            refin.Linetype = Linetype.Dashed;
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中心线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            centre.Linetype = Linetype.DashDot;
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层

            //参数
            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);

            double scale = 1; //放大系数

            double d = Convert.ToDouble(data["dc"]);
            double d1 = Convert.ToDouble(data["dcintf"]);
            double d2 = Convert.ToDouble(data["dconms"]);
            double oal = Convert.ToDouble(data["oal"]);
            double l = Convert.ToDouble(data["lf"]);
            double z = Convert.ToDouble(data["z"]);
            string bbxz = Convert.ToString(data["bbxz"]);
            double czc = Convert.ToDouble(data["czc"]);


            if (z == 1)
            {
                Vector2 v1 = new Vector2(0, 0);
                Vector2 v2 = new Vector2(v1.X + oal + 6 + d1, v1.Y);
                Vector2 v3 = new Vector2(v1.X + 3, v1.Y);
                Vector2 v4 = new Vector2(v3.X, v3.Y + d1 * 3.4 / 10.41);
                Vector2 v5 = new Vector2(v3.X + d1 * 3.4 / 10.41 / 2, v3.Y + d1 / 2);
                Vector2 v6 = new Vector2(v3.X + d1 / 2, v5.Y);
                Vector2 v7 = new Vector2(v6.X, v6.Y * -1);
                Vector2 v8 = new Vector2(v5.X, v5.Y * -1);
                Vector2 v9 = new Vector2(v4.X, v4.Y * -1);
                Vector2 v10 = new Vector2(v3.X, v3.Y + d1 * 3.4 / 10.41 * 1 / 3);
                Vector2 v11 = new Vector2(v5.X, v10.Y + (v5.Y - v4.Y));
                Vector2 v12 = new Vector2(v6.X, v11.Y);
                Vector2 v13 = new Vector2(v12.X, v12.Y * -1);
                Vector2 v14 = new Vector2(v11.X, v11.Y * -1);
                Vector2 v15 = new Vector2(v3.X, v10.Y * -1);
                Vector2 v16 = new Vector2(v3.X + d1 + d1 * 1.21 / 9.24, v12.Y);
                Vector2 v17 = new Vector2(v16.X, v3.Y + d * 7.73 / 19);
                Vector2 v18 = new Vector2(v3.X + l + d1 - l * 1.75 / 36.3, v17.Y);
                Vector2 v19 = new Vector2(v18.X, v18.Y * -1);
                Vector2 v20 = new Vector2(v16.X + l * 5.24 / 36.3, v19.Y);
                Vector2 v21 = new Vector2(v20.X, v3.Y - d / 2);
                Vector2 v22 = new Vector2(v3.X + d1, v21.Y);
                Vector2 v23 = new Vector2(v22.X, v22.Y + d * 4.95 / 19);
                Vector2 v24 = new Vector2(v21.X, v23.Y);
                Vector2 v25 = new Vector2(v16.X, v24.Y);
                Vector2 a26 = new Vector2(v25.X, v25.Y + d * 1.84 / 19);
                Vector2 v26 = new Vector2(v16.X, v13.Y);
                Vector2 v27 = new Vector2(v23.X, v23.Y * -1);
                Vector2 a27 = new Vector2(v16.X, v27.Y);
                Vector2 v28 = new Vector2(v27.X, v22.Y * -1);
                Vector2 v29 = new Vector2(v20.X, v28.Y);
                Vector2 v30 = new Vector2(v29.X, v17.Y);
                Vector2 v31 = new Vector2(v26.X + l * 21.14 / 36.3, a26.Y);
                Vector2 v32 = new Vector2(v31.X + l * 7.11 / 36.3, v20.Y);

                //作图
                Line line1 = new Line(v1, v2);
                line1.Layer = centre;
                line1.Linetype = Linetype.DashDot;
                line1.LinetypeScale = 3;
                dxf.AddEntity(line1);

                LwPolyline line2 = new LwPolyline();
                line2.Vertexes.Add(new LwPolylineVertex(v5));
                line2.Vertexes.Add(new LwPolylineVertex(v6));
                line2.Vertexes.Add(new LwPolylineVertex(v7));
                line2.Vertexes.Add(new LwPolylineVertex(v8));
                line2.Vertexes.Add(new LwPolylineVertex(v9));
                line2.Vertexes.Add(new LwPolylineVertex(v4));
                line2.Vertexes.Add(new LwPolylineVertex(v5));
                line2.Vertexes.Add(new LwPolylineVertex(v11));
                line2.Vertexes.Add(new LwPolylineVertex(v10));
                line2.Vertexes.Add(new LwPolylineVertex(v11));
                line2.Vertexes.Add(new LwPolylineVertex(v16));
                line2.Vertexes.Add(new LwPolylineVertex(v26));
                line2.Vertexes.Add(new LwPolylineVertex(v14));
                line2.Vertexes.Add(new LwPolylineVertex(v15));
                line2.Vertexes.Add(new LwPolylineVertex(v14));
                line2.Vertexes.Add(new LwPolylineVertex(v8));
                fun.PolyFill(dxf, line2, 0.2, contour);

                LwPolyline line3 = new LwPolyline();
                line3.Vertexes.Add(new LwPolylineVertex(v25));
                line3.Vertexes.Add(new LwPolylineVertex(v24));
                line3.Vertexes.Add(new LwPolylineVertex(v21));
                line3.Vertexes.Add(new LwPolylineVertex(v22));
                line3.Vertexes.Add(new LwPolylineVertex(v23));
                line3.Vertexes.Add(new LwPolylineVertex(v25));
                line3.Vertexes.Add(new LwPolylineVertex(v17));
                line3.Vertexes.Add(new LwPolylineVertex(v18));
                line3.Vertexes.Add(new LwPolylineVertex(v19));
                line3.Vertexes.Add(new LwPolylineVertex(v20));
                fun.PolyFill(dxf, line3, 0.2, contour);

                LwPolyline line5 = new LwPolyline();
                line5.Vertexes.Add(new LwPolylineVertex(a26));
                line5.Vertexes.Add(new LwPolylineVertex(v31));
                line5.Vertexes.Add(new LwPolylineVertex(v32));
                line5.Vertexes[1].Bulge = Math.Tan(-64 * pi / 180 / 4);
                fun.PolyFill(dxf, line5, 0.2, contour); 
                
                //柄部
                if (bbxz == "削平型直柄")
                {
                    double l1 = 0;
                    double l2 = 0;
                    double l3 = 0;
                    double l4 = 0;
                    double h = 0;
                    if (d2 == 12)
                    {
                        l1 = 45;
                        l2 = 22.5;
                        l3 = 8;
                        h = 10.4;
                    }
                    if (d2 == 16)
                    {
                        l1 = 48;
                        l2 = 24;
                        l3 = 10;
                        h = 14.2;
                    }
                    if (d2 == 20)
                    {
                        l1 = 50;
                        l2 = 25;
                        l3 = 11;
                        h = 18.2;
                    }
                    if (d2 == 25)
                    {
                        l1 = 56;
                        l2 = 32;
                        l3 = 12;
                        l4 = 17;
                        h = 23;
                    }
                    if (d2 == 32)
                    {
                        l1 = 60;
                        l2 = 36;
                        l3 = 14;
                        l4 = 19;
                        h = 30;
                    }
                    if (d2 == 40)
                    {
                        l1 = 70;
                        l2 = 40;
                        l3 = 14;
                        l4 = 19;
                        h = 38;
                    }
                    if (d2 == 50)
                    {
                        l1 = 80;
                        l2 = 45;
                        l3 = 18;
                        l4 = 23;
                        h = 47.8;
                    }

                    Vector2 v33 = new Vector2(v3.X + d1 + l, v3.Y + d2 * 4.92 / 12);
                    Vector2 v35 = new Vector2(v33.X, v33.Y * -1);
                    Vector2 v34 = new Vector2(v33.X + (oal - l1 - l), v33.Y);
                    Vector2 v36 = new Vector2(v34.X, v34.Y * -1);
                    Vector2 v37 = new Vector2(v34.X, v3.Y + d2 / 2);
                    Vector2 v43 = new Vector2(v3.X + d1 + oal, v3.Y + d2 * 4.11 / 12);
                    Vector2 v42 = new Vector2(v43.X - l1 * 1.93 / 36.76, v3.Y + d2 / 2);
                    Vector2 v41 = new Vector2(v43.X - l2 + l3 / 2 + (d2 - h), v42.Y);
                    Vector2 v44 = new Vector2(v43.X, v43.Y * -1);
                    Vector2 v45 = new Vector2(v42.X, v42.Y * -1);
                    Vector2 v46 = new Vector2(v43.X - l1, v45.Y);
                    Vector2 v40 = new Vector2(v43.X - l2 + l3 / 2, v45.Y + h);
                    Vector2 v39 = new Vector2(v40.X - l3, v40.Y);
                    Vector2 v38 = new Vector2(v39.X - (d2 - h), v41.Y);
                    Vector2 a1 = new Vector2(v44.X, v45.Y + h);
                    Vector2 a2 = new Vector2(v45.X, a1.Y);
                    Vector2 a3 = new Vector2(a1.X - l4, a1.Y);
                    Vector2 a4 = new Vector2(a3.X - (d2 - h), v41.Y);
                    if (d2 <= 20)
                    {
                        LwPolyline line7 = new LwPolyline();
                        line7.Vertexes.Add(new LwPolylineVertex(v42));
                        line7.Vertexes.Add(new LwPolylineVertex(v45));
                        line7.Vertexes.Add(new LwPolylineVertex(v44));
                        line7.Vertexes.Add(new LwPolylineVertex(v43));
                        line7.Vertexes.Add(new LwPolylineVertex(v42));
                        line7.Vertexes.Add(new LwPolylineVertex(v41));
                        line7.Vertexes.Add(new LwPolylineVertex(v40));
                        line7.Vertexes.Add(new LwPolylineVertex(v39));
                        line7.Vertexes.Add(new LwPolylineVertex(v38));
                        line7.Vertexes.Add(new LwPolylineVertex(v37));
                        line7.Vertexes.Add(new LwPolylineVertex(v36));
                        line7.Vertexes.Add(new LwPolylineVertex(v46));
                        line7.Vertexes.Add(new LwPolylineVertex(v45));
                        fun.PolyFill(dxf, line7, 0.2, contour);

                    }
                    if (d2 > 20)
                    {
                        LwPolyline line7 = new LwPolyline();
                        line7.Vertexes.Add(new LwPolylineVertex(a2));
                        line7.Vertexes.Add(new LwPolylineVertex(v45));
                        line7.Vertexes.Add(new LwPolylineVertex(v44));
                        line7.Vertexes.Add(new LwPolylineVertex(a1));
                        line7.Vertexes.Add(new LwPolylineVertex(a3));
                        line7.Vertexes.Add(new LwPolylineVertex(a4));
                        line7.Vertexes.Add(new LwPolylineVertex(v41));
                        line7.Vertexes.Add(new LwPolylineVertex(v40));
                        line7.Vertexes.Add(new LwPolylineVertex(v39));
                        line7.Vertexes.Add(new LwPolylineVertex(v38));
                        line7.Vertexes.Add(new LwPolylineVertex(v37));
                        line7.Vertexes.Add(new LwPolylineVertex(v36));
                        line7.Vertexes.Add(new LwPolylineVertex(v46));
                        line7.Vertexes.Add(new LwPolylineVertex(v45));
                        fun.PolyFill(dxf, line7, 0.2, contour);

                    }
                    LwPolyline line6 = new LwPolyline();
                    line6.Vertexes.Add(new LwPolylineVertex(v33));
                    line6.Vertexes.Add(new LwPolylineVertex(v35));
                    line6.Vertexes.Add(new LwPolylineVertex(v36));
                    line6.Vertexes.Add(new LwPolylineVertex(v34));
                    line6.Vertexes.Add(new LwPolylineVertex(v33));
                    line6.Vertexes.Add(new LwPolylineVertex(v18));
                    line6.Vertexes.Add(new LwPolylineVertex(v19));
                    line6.Vertexes.Add(new LwPolylineVertex(v35));
                    fun.PolyFill(dxf, line6, 0.2, contour);

                    //标注

                    double height = 5;
                    double arrowsize = 1;
                    double exline = 2;

                    fun.dimrot1(dxf, v5, v8, 90, d1/2 +10, 1, height, arrowsize, exline, "d1=" + d1, "", "");

                    fun.dimrot1(dxf, v28, v22, 90, d1/2 +20, 1, height, arrowsize, exline, "d=" + d, "", "");

                    fun.dimrot1(dxf, v22, v35, 180, d1/2 +10, 1, height, arrowsize, exline, "l=" + l, "", "");

                    fun.dimrot1(dxf, v22, v44, 180, d1/2 +20, 1, height, arrowsize, exline, "L=" + oal, "", "");
                    if (d2 <= 20)
                    {
                        fun.dimrot1(dxf, v42, v45, -90, d1/ 2, 1, height, arrowsize, exline, "d2=" + d2, "", "");
                    }
                    if (d2 > 20)
                    {
                        fun.dimrot1(dxf, a4, v45, -90, d1, 1, height, arrowsize, exline, "d2=" + d2, "", "");
                    }


                }
                if (bbxz == "莫氏锥柄")
                {
                    double db = 0;
                    double ds = 0;
                    double tg = 0;
                    double b = 0;
                    double e = 0;
                    if (czc == 2)
                    {
                        db = 17.78;
                        ds = 14.6;
                        tg = 0.04995;
                        b = 6.3;
                        e = 16;
                    }
                    if (czc == 3)
                    {
                        db = 23.825;
                        ds = 19.8;
                        tg = 0.05020;
                        b = 7.9;
                        e = 20;
                    }
                    if (czc == 4)
                    {
                        db = 31.267;
                        ds = 25.9;
                        tg = 0.05194;
                        b = 11.9;
                        e = 24;
                    }
                    double l3 = (db - ds) / tg;
                    Vector2 v33 = new Vector2(v3.X + d1 + l, v3.Y + db * 6.7 / 8.16 / 2);
                    Vector2 v35 = new Vector2(v33.X, v33.Y * -1);
                    Vector2 v34 = new Vector2(v33.X + oal - l3 - e - l, v33.Y);
                    Vector2 v36 = new Vector2(v34.X, v35.Y);
                    Vector2 v37 = new Vector2(v34.X, v3.Y + db / 2);
                    Vector2 v38 = new Vector2(v37.X + l3, v3.Y + ds / 2);
                    Vector2 v39 = new Vector2(v38.X + e * 4.52 / 7.75, v3.Y + b / 2);
                    Vector2 v40 = new Vector2(v38.X + e, v39.Y);
                    Vector2 v41 = new Vector2(v40.X, v40.Y * -1);
                    Vector2 v42 = new Vector2(v39.X, v39.Y * -1);
                    Vector2 v43 = new Vector2(v38.X, v38.Y * -1);
                    Vector2 v44 = new Vector2(v37.X, v37.Y * -1);

                    LwPolyline line6 = new LwPolyline();
                    line6.Vertexes.Add(new LwPolylineVertex(v39));
                    line6.Vertexes.Add(new LwPolylineVertex(v42));
                    line6.Vertexes.Add(new LwPolylineVertex(v41));
                    line6.Vertexes.Add(new LwPolylineVertex(v40));
                    line6.Vertexes.Add(new LwPolylineVertex(v39));
                    line6.Vertexes.Add(new LwPolylineVertex(v38));
                    line6.Vertexes.Add(new LwPolylineVertex(v37));
                    line6.Vertexes.Add(new LwPolylineVertex(v44));
                    line6.Vertexes.Add(new LwPolylineVertex(v43));
                    line6.Vertexes.Add(new LwPolylineVertex(v42));
                    line6.Vertexes[4].Bulge = Math.Tan(-39 * pi / 180 / 4);
                    line6.Vertexes[8].Bulge = Math.Tan(-39 * pi / 180 / 4);
                    fun.PolyFill(dxf, line6, 0.2, contour);

                    LwPolyline line7 = new LwPolyline();
                    line7.Vertexes.Add(new LwPolylineVertex(v33));
                    line7.Vertexes.Add(new LwPolylineVertex(v35));
                    line7.Vertexes.Add(new LwPolylineVertex(v36));
                    line7.Vertexes.Add(new LwPolylineVertex(v34));
                    line7.Vertexes.Add(new LwPolylineVertex(v33));
                    line7.Vertexes.Add(new LwPolylineVertex(v18));
                    line7.Vertexes.Add(new LwPolylineVertex(v19));
                    line7.Vertexes.Add(new LwPolylineVertex(v35));
                    fun.PolyFill(dxf, line7, 0.2, contour);

                    //标注

                    double height = 5;
                    double arrowsize = 1;
                    double exline = 2;

                    fun.dimrot1(dxf, v5, v8, 90, d1 / 2 +10, 1, height, arrowsize, exline, "d1=" + d1, "", "");

                    fun.dimrot1(dxf, v28, v22, 90, d1 / 2 +20, 1, height, arrowsize, exline, "d=" + d, "", "");

                    fun.dimrot1(dxf, v22, v35, 180, d1 / 2 +10, 1, height, arrowsize, exline, "l=" + l, "", "");

                    fun.dimrot1(dxf, v22, v41, 180, d1 /2 +20, 1, height, arrowsize, exline, "L=" + oal, "", "");


                }
                if (bbxz == "圆柱销快换柄")
                {
                    double L1 = 0;
                    double l1 = 0;
                    double l2 = 0;
                    double l3 = 0;
                    double d3 = 0;
                    double c = 0;
                    double h = 0;
                    if (d2 == 22)
                    {
                        L1 = 42;
                        l1 = 14;
                        l2 = 10.5;
                        l3 = 22.5;
                        d3 = 20;
                        c = 7.5;
                        h = 19;
                    }
                    if (d2 == 40)
                    {
                        L1 = 55;
                        l1 = 22;
                        l2 = 15.5;
                        l3 = 30.5;
                        d3 = 38;
                        c = 13;
                        h = 35;
                    }
                    Vector2 v33 = new Vector2(v3.X + d1 + l, v3.Y + d2 * 5.89 / 14.2);
                    Vector2 v35 = new Vector2(v33.X, v33.Y * -1);
                    Vector2 v34 = new Vector2(v33.X + oal - l - L1, v33.Y);
                    Vector2 v36 = new Vector2(v34.X, v35.Y);
                    Vector2 v37 = new Vector2(v34.X, v3.Y + d2 / 2);
                    Vector2 v38 = new Vector2(v37.X + l2 - (d2 - d3) / 2, v37.Y);
                    Vector2 v39 = new Vector2(v37.X + l2, v3.Y + d3 / 2);
                    Vector2 v40 = new Vector2(v39.X + (L1 - l2 - l3), v39.Y);
                    Vector2 v41 = new Vector2(v40.X + (d2 - d3) / 2, v38.Y);
                    Vector2 v42 = new Vector2(v34.X + L1 - L1 * 1.85 / 40.09, v41.Y);
                    Vector2 v43 = new Vector2(v34.X + L1, v3.Y + d2 * 4.1 / 14.2);
                    Vector2 v44 = new Vector2(v43.X, v42.Y - h);
                    Vector2 v45 = new Vector2(v42.X, v44.Y);
                    Vector2 v46 = new Vector2(v44.X - l3 * 13.28 / 24.14, v45.Y);
                    Vector2 v47 = new Vector2(v44.X - l1, v41.Y * -1);
                    Vector2 v48 = new Vector2(v41.X, v47.Y);
                    Vector2 v49 = new Vector2(v40.X, v40.Y * -1);
                    Vector2 v50 = new Vector2(v39.X, v39.Y * -1);
                    Vector2 v51 = new Vector2(v38.X, v38.Y * -1);
                    Vector2 v52 = new Vector2(v37.X, v37.Y * -1);
                    Vector2 v53 = new Vector2(v44.X - c, v3.Y);
                    Vector2 v56 = new Vector2(v53.X - l1 * 3.58 / 18, v45.Y);
                    Vector2 v55 = new Vector2(v56.X, v3.Y);
                    Vector2 v54 = new Vector2(v53.X + l1 * 3.58 / 18, v55.Y);
                    Vector2 v61 = new Vector2(v54.X, v45.Y);
                    Vector2 v57 = new Vector2(v53.X - l1 * 2.24 / 18, v45.Y);
                    Vector2 v58 = new Vector2(v57.X, v3.Y);
                    Vector2 v59 = new Vector2(v53.X + l1 * 2.24 / 18, v53.Y);
                    Vector2 v60 = new Vector2(v59.X, v45.Y);

                    LwPolyline line7 = new LwPolyline();
                    line7.Vertexes.Add(new LwPolylineVertex(v38));
                    line7.Vertexes.Add(new LwPolylineVertex(v51));
                    line7.Vertexes.Add(new LwPolylineVertex(v52));
                    line7.Vertexes.Add(new LwPolylineVertex(v37));
                    line7.Vertexes.Add(new LwPolylineVertex(v38));
                    line7.Vertexes.Add(new LwPolylineVertex(v39));
                    line7.Vertexes.Add(new LwPolylineVertex(v50));
                    line7.Vertexes.Add(new LwPolylineVertex(v51));
                    line7.Vertexes.Add(new LwPolylineVertex(v50));
                    line7.Vertexes.Add(new LwPolylineVertex(v49));
                    line7.Vertexes.Add(new LwPolylineVertex(v40));
                    line7.Vertexes.Add(new LwPolylineVertex(v39));
                    line7.Vertexes.Add(new LwPolylineVertex(v40));
                    line7.Vertexes.Add(new LwPolylineVertex(v41));
                    line7.Vertexes.Add(new LwPolylineVertex(v48));
                    line7.Vertexes.Add(new LwPolylineVertex(v49));
                    fun.PolyFill(dxf, line7, 0.2, contour);

                    LwPolyline line6 = new LwPolyline();
                    line6.Vertexes.Add(new LwPolylineVertex(v33));
                    line6.Vertexes.Add(new LwPolylineVertex(v35));
                    line6.Vertexes.Add(new LwPolylineVertex(v36));
                    line6.Vertexes.Add(new LwPolylineVertex(v34));
                    line6.Vertexes.Add(new LwPolylineVertex(v33));
                    line6.Vertexes.Add(new LwPolylineVertex(v18));
                    line6.Vertexes.Add(new LwPolylineVertex(v19));
                    line6.Vertexes.Add(new LwPolylineVertex(v35));
                    fun.PolyFill(dxf, line6, 0.2, contour);

                    LwPolyline line8 = new LwPolyline();
                    line8.Vertexes.Add(new LwPolylineVertex(v48));
                    line8.Vertexes.Add(new LwPolylineVertex(v47));
                    line8.Vertexes.Add(new LwPolylineVertex(v46));
                    line8.Vertexes.Add(new LwPolylineVertex(v44));
                    line8.Vertexes.Add(new LwPolylineVertex(v43));
                    line8.Vertexes.Add(new LwPolylineVertex(v42));
                    line8.Vertexes.Add(new LwPolylineVertex(v45));
                    line8.Vertexes.Add(new LwPolylineVertex(v42));
                    line8.Vertexes.Add(new LwPolylineVertex(v41));
                    line8.Vertexes[1].Bulge = Math.Tan(-50 * pi / 180 / 4);
                    fun.PolyFill(dxf, line8, 0.2, contour);

                    LwPolyline line4 = new LwPolyline();
                    line4.Vertexes.Add(new LwPolylineVertex(v56));
                    line4.Vertexes.Add(new LwPolylineVertex(v55));
                    line4.Vertexes.Add(new LwPolylineVertex(v54));
                    line4.Vertexes.Add(new LwPolylineVertex(v61));
                    line4.Vertexes.Add(new LwPolylineVertex(v60));
                    line4.Vertexes.Add(new LwPolylineVertex(v59));
                    line4.Vertexes.Add(new LwPolylineVertex(v58));
                    line4.Vertexes.Add(new LwPolylineVertex(v57));
                    line4.Vertexes[1].Bulge = Math.Tan(-180 * pi / 180 / 4);
                    line4.Vertexes[5].Bulge = Math.Tan(180 * pi / 180 / 4);
                    fun.PolyFill(dxf, line4, 0.2, contour);

                    //标注

                    double height = 5;
                    double arrowsize = 1;
                    double exline = 2;

                    fun.dimrot1(dxf, v5, v8, 90, d1 / 2 +10, 1, height, arrowsize, exline, "d1=" + d1, "", "");

                    fun.dimrot1(dxf, v28, v22, 90, d1 / 2 +20, 1, height, arrowsize, exline, "d=" + d, "", "");

                    fun.dimrot1(dxf, v22, v35, 180, d1 / 2 +10, 1, height, arrowsize, exline, "l=" + l, "", "");

                    fun.dimrot1(dxf, v22, v44, 180, d1 / 2 +10, 1, height, arrowsize, exline, "L=" + oal, "", "");

                    fun.dimrot1(dxf, v42, v47, -90, l3 +10, 1, height, arrowsize, exline, "d2=" + d2, "", "");


                }

            }
            if (z == 2)
            {
                Vector2 v1 = new Vector2(0, 0);
                Vector2 v2 = new Vector2(v1.X + oal + 6 + d1, v1.Y);
                Vector2 v3 = new Vector2(v1.X + 3, v1.Y);
                Vector2 v4 = new Vector2(v3.X, v3.Y + d1 * 3.4 / 10.41);
                Vector2 v5 = new Vector2(v3.X + d1 * 3.4 / 10.41 / 2, v3.Y + d1 / 2);
                Vector2 v6 = new Vector2(v3.X + d1 / 2, v5.Y);
                Vector2 v7 = new Vector2(v6.X, v6.Y * -1);
                Vector2 v8 = new Vector2(v5.X, v5.Y * -1);
                Vector2 v9 = new Vector2(v4.X, v4.Y * -1);
                Vector2 v10 = new Vector2(v3.X, v3.Y + d1 * 3.4 / 10.41 * 1 / 3);
                Vector2 v11 = new Vector2(v5.X, v10.Y + (v5.Y - v4.Y));
                Vector2 v12 = new Vector2(v6.X, v11.Y);
                Vector2 v13 = new Vector2(v12.X, v12.Y * -1);
                Vector2 v14 = new Vector2(v11.X, v11.Y * -1);
                Vector2 v15 = new Vector2(v3.X, v10.Y * -1);
                Vector2 v16 = new Vector2(v3.X + d1 + d1 * 1.21 / 9.24, v12.Y);
                Vector2 v17 = new Vector2(v16.X, v3.Y + d * 7.73 / 19);
                Vector2 v18 = new Vector2(v3.X + l + d1 - l * 1.75 / 36.3, v17.Y);
                Vector2 v19 = new Vector2(v18.X, v18.Y * -1);
                Vector2 v20 = new Vector2(v16.X + l * 5.24 / 36.3, v19.Y);
                Vector2 v21 = new Vector2(v20.X, v3.Y - d / 2);
                Vector2 v22 = new Vector2(v3.X + d1, v21.Y);
                Vector2 v23 = new Vector2(v22.X, v22.Y + d * 4.95 / 19);
                Vector2 v24 = new Vector2(v21.X, v23.Y);
                Vector2 v25 = new Vector2(v16.X, v24.Y);
                Vector2 a26 = new Vector2(v25.X, v25.Y + d * 1.84 / 19);
                Vector2 v26 = new Vector2(v16.X, v13.Y);
                Vector2 v27 = new Vector2(v23.X, v23.Y * -1);
                Vector2 a27 = new Vector2(v16.X, v27.Y);
                Vector2 v28 = new Vector2(v27.X, v22.Y * -1);
                Vector2 v29 = new Vector2(v20.X, v28.Y);
                Vector2 v30 = new Vector2(v29.X, v17.Y);
                Vector2 v31 = new Vector2(v26.X + l * 21.14 / 36.3, a26.Y);
                Vector2 v32 = new Vector2(v31.X + l * 7.11 / 36.3, v20.Y);

                //作图
                Line line1 = new Line(v1, v2);
                line1.Layer = centre;
                line1.Linetype = Linetype.DashDot;
                line1.LinetypeScale = 3;
                dxf.AddEntity(line1);

                LwPolyline line2 = new LwPolyline();
                line2.Vertexes.Add(new LwPolylineVertex(v5));
                line2.Vertexes.Add(new LwPolylineVertex(v6));
                line2.Vertexes.Add(new LwPolylineVertex(v7));
                line2.Vertexes.Add(new LwPolylineVertex(v8));
                line2.Vertexes.Add(new LwPolylineVertex(v9));
                line2.Vertexes.Add(new LwPolylineVertex(v4));
                line2.Vertexes.Add(new LwPolylineVertex(v5));
                line2.Vertexes.Add(new LwPolylineVertex(v11));
                line2.Vertexes.Add(new LwPolylineVertex(v10));
                line2.Vertexes.Add(new LwPolylineVertex(v11));
                line2.Vertexes.Add(new LwPolylineVertex(v16));
                line2.Vertexes.Add(new LwPolylineVertex(v26));
                line2.Vertexes.Add(new LwPolylineVertex(v14));
                line2.Vertexes.Add(new LwPolylineVertex(v15));
                line2.Vertexes.Add(new LwPolylineVertex(v14));
                line2.Vertexes.Add(new LwPolylineVertex(v8));
                fun.PolyFill(dxf, line2, 0.2, contour);

                LwPolyline line3 = new LwPolyline();
                line3.Vertexes.Add(new LwPolylineVertex(v25));
                line3.Vertexes.Add(new LwPolylineVertex(v24));
                line3.Vertexes.Add(new LwPolylineVertex(v21));
                line3.Vertexes.Add(new LwPolylineVertex(v22));
                line3.Vertexes.Add(new LwPolylineVertex(v23));
                line3.Vertexes.Add(new LwPolylineVertex(v25));
                line3.Vertexes.Add(new LwPolylineVertex(v17));
                line3.Vertexes.Add(new LwPolylineVertex(v18));
                line3.Vertexes.Add(new LwPolylineVertex(v19));
                line3.Vertexes.Add(new LwPolylineVertex(v20));
                fun.PolyFill(dxf, line3, 0.2, contour);

                double a = v27.Y - v3.Y;
                double b1 = v16.Y - v3.Y;
                if (a <= b1)
                {
                    LwPolyline line4 = new LwPolyline();
                    line4.Vertexes.Add(new LwPolylineVertex(v27));
                    line4.Vertexes.Add(new LwPolylineVertex(v28));
                    line4.Vertexes.Add(new LwPolylineVertex(v29));
                    line4.Vertexes.Add(new LwPolylineVertex(v30));
                    fun.PolyFill(dxf, line4, 0.2, contour);
                }
                else
                {
                    LwPolyline line4 = new LwPolyline();
                    line4.Vertexes.Add(new LwPolylineVertex(a27));
                    line4.Vertexes.Add(new LwPolylineVertex(v27));
                    line4.Vertexes.Add(new LwPolylineVertex(v28));
                    line4.Vertexes.Add(new LwPolylineVertex(v29));
                    line4.Vertexes.Add(new LwPolylineVertex(v30));
                    fun.PolyFill(dxf, line4, 0.2, contour);
                }
                LwPolyline line5 = new LwPolyline();
                line5.Vertexes.Add(new LwPolylineVertex(a26));
                line5.Vertexes.Add(new LwPolylineVertex(v31));
                line5.Vertexes.Add(new LwPolylineVertex(v32));
                line5.Vertexes[1].Bulge = Math.Tan(-64 * pi / 180 / 4);
                fun.PolyFill(dxf, line5, 0.2, contour);
                //柄部
                if (bbxz == "削平型直柄")
                {
                    double l1 = 0;
                    double l2 = 0;
                    double l3 = 0;
                    double l4 = 0;
                    double h = 0;
                    if (d2 == 12)
                    {
                        l1 = 45;
                        l2 = 22.5;
                        l3 = 8;
                        h = 10.4;
                    }
                    if (d2 == 16)
                    {
                        l1 = 48;
                        l2 = 24;
                        l3 = 10;
                        h = 14.2;
                    }
                    if (d2 == 20)
                    {
                        l1 = 50;
                        l2 = 25;
                        l3 = 11;
                        h = 18.2;
                    }
                    if (d2 == 25)
                    {
                        l1 = 56;
                        l2 = 32;
                        l3 = 12;
                        l4 = 17;
                        h = 23;
                    }
                    if (d2 == 32)
                    {
                        l1 = 60;
                        l2 = 36;
                        l3 = 14;
                        l4 = 19;
                        h = 30;
                    }
                    if (d2 == 40)
                    {
                        l1 = 70;
                        l2 = 40;
                        l3 = 14;
                        l4 = 19;
                        h = 38;
                    }
                    if (d2 == 50)
                    {
                        l1 = 80;
                        l2 = 45;
                        l3 = 18;
                        l4 = 23;
                        h = 47.8;
                    }

                    Vector2 v33 = new Vector2(v3.X + d1 + l, v3.Y + d2 * 4.92 / 12);
                    Vector2 v35 = new Vector2(v33.X, v33.Y * -1);
                    Vector2 v34 = new Vector2(v33.X + (oal - l1 - l), v33.Y);
                    Vector2 v36 = new Vector2(v34.X, v34.Y * -1);
                    Vector2 v37 = new Vector2(v34.X, v3.Y + d2 / 2);
                    Vector2 v43 = new Vector2(v3.X + d1 + oal, v3.Y + d2 * 4.11 / 12);
                    Vector2 v42 = new Vector2(v43.X - l1 * 1.93 / 36.76, v3.Y + d2 / 2);
                    Vector2 v41 = new Vector2(v43.X - l2 + l3 / 2 + (d2 - h), v42.Y);
                    Vector2 v44 = new Vector2(v43.X, v43.Y * -1);
                    Vector2 v45 = new Vector2(v42.X, v42.Y * -1);
                    Vector2 v46 = new Vector2(v43.X - l1, v45.Y);
                    Vector2 v40 = new Vector2(v43.X - l2 + l3 / 2, v45.Y + h);
                    Vector2 v39 = new Vector2(v40.X - l3, v40.Y);
                    Vector2 v38 = new Vector2(v39.X - (d2 - h), v41.Y);
                    Vector2 a1 = new Vector2(v44.X, v45.Y + h);
                    Vector2 a2 = new Vector2(v45.X, a1.Y);
                    Vector2 a3 = new Vector2(a1.X - l4, a1.Y);
                    Vector2 a4 = new Vector2(a3.X - (d2 - h), v41.Y);
                    if (d2 <= 20)
                    {
                        LwPolyline line7 = new LwPolyline();
                        line7.Vertexes.Add(new LwPolylineVertex(v42));
                        line7.Vertexes.Add(new LwPolylineVertex(v45));
                        line7.Vertexes.Add(new LwPolylineVertex(v44));
                        line7.Vertexes.Add(new LwPolylineVertex(v43));
                        line7.Vertexes.Add(new LwPolylineVertex(v42));
                        line7.Vertexes.Add(new LwPolylineVertex(v41));
                        line7.Vertexes.Add(new LwPolylineVertex(v40));
                        line7.Vertexes.Add(new LwPolylineVertex(v39));
                        line7.Vertexes.Add(new LwPolylineVertex(v38));
                        line7.Vertexes.Add(new LwPolylineVertex(v37));
                        line7.Vertexes.Add(new LwPolylineVertex(v36));
                        line7.Vertexes.Add(new LwPolylineVertex(v46));
                        line7.Vertexes.Add(new LwPolylineVertex(v45));
                        fun.PolyFill(dxf, line7, 0.2, contour);

                    }
                    if (d2 > 20)
                    {
                        LwPolyline line7 = new LwPolyline();
                        line7.Vertexes.Add(new LwPolylineVertex(a2));
                        line7.Vertexes.Add(new LwPolylineVertex(v45));
                        line7.Vertexes.Add(new LwPolylineVertex(v44));
                        line7.Vertexes.Add(new LwPolylineVertex(a1));
                        line7.Vertexes.Add(new LwPolylineVertex(a3));
                        line7.Vertexes.Add(new LwPolylineVertex(a4));
                        line7.Vertexes.Add(new LwPolylineVertex(v41));
                        line7.Vertexes.Add(new LwPolylineVertex(v40));
                        line7.Vertexes.Add(new LwPolylineVertex(v39));
                        line7.Vertexes.Add(new LwPolylineVertex(v38));
                        line7.Vertexes.Add(new LwPolylineVertex(v37));
                        line7.Vertexes.Add(new LwPolylineVertex(v36));
                        line7.Vertexes.Add(new LwPolylineVertex(v46));
                        line7.Vertexes.Add(new LwPolylineVertex(v45));
                        fun.PolyFill(dxf, line7, 0.2, contour);

                    }
                    LwPolyline line6 = new LwPolyline();
                    line6.Vertexes.Add(new LwPolylineVertex(v33));
                    line6.Vertexes.Add(new LwPolylineVertex(v35));
                    line6.Vertexes.Add(new LwPolylineVertex(v36));
                    line6.Vertexes.Add(new LwPolylineVertex(v34));
                    line6.Vertexes.Add(new LwPolylineVertex(v33));
                    line6.Vertexes.Add(new LwPolylineVertex(v18));
                    line6.Vertexes.Add(new LwPolylineVertex(v19));
                    line6.Vertexes.Add(new LwPolylineVertex(v35));
                    fun.PolyFill(dxf, line6, 0.2, contour);

                    //标注

                    double height = 5;
                    double arrowsize = 1;
                    double exline = 2;

                    fun.dimrot1(dxf, v5, v8, 90, d1 / 2+10, 1, height, arrowsize, exline, "d1=" + d1, "", "");

                    fun.dimrot1(dxf, v28, v22, 90, d1 / 2+20, 1, height, arrowsize, exline, "d=" + d, "", "");

                    fun.dimrot1(dxf, v22, v35, 180, d1 / 2+10, 1, height, arrowsize, exline, "l=" + l, "", "");

                    fun.dimrot1(dxf, v22, v44, 180, d1 / 2+20, 1, height, arrowsize, exline, "L=" + oal, "", "");
                    if (d2 <= 20)
                    {
                        fun.dimrot1(dxf, v42, v45, -90, d1 / 2, 1, height, arrowsize, exline, "d2=" + d2, "", "");
                    }
                    if (d2 > 20)
                    {
                        fun.dimrot1(dxf, a4, v45, -90, d1, 1, height, arrowsize, exline, "d2=" + d2, "", "");
                    }


                }
                if (bbxz == "莫氏锥柄")
                {
                    double db = 0;
                    double ds = 0;
                    double tg = 0;
                    double b = 0;
                    double e = 0;
                    if (czc == 2)
                    {
                        db = 17.78;
                        ds = 14.6;
                        tg = 0.04995;
                        b = 6.3;
                        e = 16;
                    }
                    if (czc == 3)
                    {
                        db = 23.825;
                        ds = 19.8;
                        tg = 0.05020;
                        b = 7.9;
                        e = 20;
                    }
                    if (czc == 4)
                    {
                        db = 31.267;
                        ds = 25.9;
                        tg = 0.05194;
                        b = 11.9;
                        e = 24;
                    }
                    double l3 = (db - ds) / tg;
                    Vector2 v33 = new Vector2(v3.X + d1 + l, v3.Y + db * 6.7 / 8.16 / 2);
                    Vector2 v35 = new Vector2(v33.X, v33.Y * -1);
                    Vector2 v34 = new Vector2(v33.X + oal - l3 - e - l, v33.Y);
                    Vector2 v36 = new Vector2(v34.X, v35.Y);
                    Vector2 v37 = new Vector2(v34.X, v3.Y + db / 2);
                    Vector2 v38 = new Vector2(v37.X + l3, v3.Y + ds / 2);
                    Vector2 v39 = new Vector2(v38.X + e * 4.52 / 7.75, v3.Y + b / 2);
                    Vector2 v40 = new Vector2(v38.X + e, v39.Y);
                    Vector2 v41 = new Vector2(v40.X, v40.Y * -1);
                    Vector2 v42 = new Vector2(v39.X, v39.Y * -1);
                    Vector2 v43 = new Vector2(v38.X, v38.Y * -1);
                    Vector2 v44 = new Vector2(v37.X, v37.Y * -1);

                    LwPolyline line6 = new LwPolyline();
                    line6.Vertexes.Add(new LwPolylineVertex(v39));
                    line6.Vertexes.Add(new LwPolylineVertex(v42));
                    line6.Vertexes.Add(new LwPolylineVertex(v41));
                    line6.Vertexes.Add(new LwPolylineVertex(v40));
                    line6.Vertexes.Add(new LwPolylineVertex(v39));
                    line6.Vertexes.Add(new LwPolylineVertex(v38));
                    line6.Vertexes.Add(new LwPolylineVertex(v37));
                    line6.Vertexes.Add(new LwPolylineVertex(v44));
                    line6.Vertexes.Add(new LwPolylineVertex(v43));
                    line6.Vertexes.Add(new LwPolylineVertex(v42));
                    line6.Vertexes[4].Bulge = Math.Tan(-39 * pi / 180 / 4);
                    line6.Vertexes[8].Bulge = Math.Tan(-39 * pi / 180 / 4);
                    fun.PolyFill(dxf, line6, 0.2, contour);

                    LwPolyline line7 = new LwPolyline();
                    line7.Vertexes.Add(new LwPolylineVertex(v33));
                    line7.Vertexes.Add(new LwPolylineVertex(v35));
                    line7.Vertexes.Add(new LwPolylineVertex(v36));
                    line7.Vertexes.Add(new LwPolylineVertex(v34));
                    line7.Vertexes.Add(new LwPolylineVertex(v33));
                    line7.Vertexes.Add(new LwPolylineVertex(v18));
                    line7.Vertexes.Add(new LwPolylineVertex(v19));
                    line7.Vertexes.Add(new LwPolylineVertex(v35));
                    fun.PolyFill(dxf, line7, 0.2, contour);

                    //标注

                    double height = 5;
                    double arrowsize = 1;
                    double exline = 2;

                    fun.dimrot1(dxf, v5, v8, 90, d1 / 2 +10, 1, height, arrowsize, exline, "d1=" + d1, "", "");

                    fun.dimrot1(dxf, v28, v22, 90, d1 / 2 +20, 1, height, arrowsize, exline, "d=" + d, "", "");

                    fun.dimrot1(dxf, v22, v35, 180, d1 / 2 +10, 1, height, arrowsize, exline, "l=" + l, "", "");

                    fun.dimrot1(dxf, v22, v41, 180, d1 / 2 +20, 1, height, arrowsize, exline, "L=" + oal, "", "");


                }
                if (bbxz == "圆柱销快换柄")
                {
                    double L1 = 0;
                    double l1 = 0;
                    double l2 = 0;
                    double l3 = 0;
                    double d3 = 0;
                    double c = 0;
                    double h = 0;
                    if (d2 == 22)
                    {
                        L1 = 42;
                        l1 = 14;
                        l2 = 10.5;
                        l3 = 22.5;
                        d3 = 20;
                        c = 7.5;
                        h = 19;
                    }
                    if (d2 == 40)
                    {
                        L1 = 55;
                        l1 = 22;
                        l2 = 15.5;
                        l3 = 30.5;
                        d3 = 38;
                        c = 13;
                        h = 35;
                    }
                    Vector2 v33 = new Vector2(v3.X + d1 + l, v3.Y + d2 * 5.89 / 14.2);
                    Vector2 v35 = new Vector2(v33.X, v33.Y * -1);
                    Vector2 v34 = new Vector2(v33.X + oal - l - L1, v33.Y);
                    Vector2 v36 = new Vector2(v34.X, v35.Y);
                    Vector2 v37 = new Vector2(v34.X, v3.Y + d2 / 2);
                    Vector2 v38 = new Vector2(v37.X + l2 - (d2 - d3) / 2, v37.Y);
                    Vector2 v39 = new Vector2(v37.X + l2, v3.Y + d3 / 2);
                    Vector2 v40 = new Vector2(v39.X + (L1 - l2 - l3), v39.Y);
                    Vector2 v41 = new Vector2(v40.X + (d2 - d3) / 2, v38.Y);
                    Vector2 v42 = new Vector2(v34.X + L1 - L1 * 1.85 / 40.09, v41.Y);
                    Vector2 v43 = new Vector2(v34.X + L1, v3.Y + d2 * 4.1 / 14.2);
                    Vector2 v44 = new Vector2(v43.X, v42.Y - h);
                    Vector2 v45 = new Vector2(v42.X, v44.Y);
                    Vector2 v46 = new Vector2(v44.X - l3 * 13.28 / 24.14, v45.Y);
                    Vector2 v47 = new Vector2(v44.X - l1, v41.Y * -1);
                    Vector2 v48 = new Vector2(v41.X, v47.Y);
                    Vector2 v49 = new Vector2(v40.X, v40.Y * -1);
                    Vector2 v50 = new Vector2(v39.X, v39.Y * -1);
                    Vector2 v51 = new Vector2(v38.X, v38.Y * -1);
                    Vector2 v52 = new Vector2(v37.X, v37.Y * -1);
                    Vector2 v53 = new Vector2(v44.X - c, v3.Y);
                    Vector2 v56 = new Vector2(v53.X - l1 * 3.58 / 18, v45.Y);
                    Vector2 v55 = new Vector2(v56.X, v3.Y);
                    Vector2 v54 = new Vector2(v53.X + l1 * 3.58 / 18, v55.Y);
                    Vector2 v61 = new Vector2(v54.X, v45.Y);
                    Vector2 v57 = new Vector2(v53.X - l1 * 2.24 / 18, v45.Y);
                    Vector2 v58 = new Vector2(v57.X, v3.Y);
                    Vector2 v59 = new Vector2(v53.X + l1 * 2.24 / 18, v53.Y);
                    Vector2 v60 = new Vector2(v59.X, v45.Y);

                    LwPolyline line7 = new LwPolyline();
                    line7.Vertexes.Add(new LwPolylineVertex(v38));
                    line7.Vertexes.Add(new LwPolylineVertex(v51));
                    line7.Vertexes.Add(new LwPolylineVertex(v52));
                    line7.Vertexes.Add(new LwPolylineVertex(v37));
                    line7.Vertexes.Add(new LwPolylineVertex(v38));
                    line7.Vertexes.Add(new LwPolylineVertex(v39));
                    line7.Vertexes.Add(new LwPolylineVertex(v50));
                    line7.Vertexes.Add(new LwPolylineVertex(v51));
                    line7.Vertexes.Add(new LwPolylineVertex(v50));
                    line7.Vertexes.Add(new LwPolylineVertex(v49));
                    line7.Vertexes.Add(new LwPolylineVertex(v40));
                    line7.Vertexes.Add(new LwPolylineVertex(v39));
                    line7.Vertexes.Add(new LwPolylineVertex(v40));
                    line7.Vertexes.Add(new LwPolylineVertex(v41));
                    line7.Vertexes.Add(new LwPolylineVertex(v48));
                    line7.Vertexes.Add(new LwPolylineVertex(v49));
                    fun.PolyFill(dxf, line7, 0.2, contour);

                    LwPolyline line6 = new LwPolyline();
                    line6.Vertexes.Add(new LwPolylineVertex(v33));
                    line6.Vertexes.Add(new LwPolylineVertex(v35));
                    line6.Vertexes.Add(new LwPolylineVertex(v36));
                    line6.Vertexes.Add(new LwPolylineVertex(v34));
                    line6.Vertexes.Add(new LwPolylineVertex(v33));
                    line6.Vertexes.Add(new LwPolylineVertex(v18));
                    line6.Vertexes.Add(new LwPolylineVertex(v19));
                    line6.Vertexes.Add(new LwPolylineVertex(v35));
                    fun.PolyFill(dxf, line6, 0.2, contour);

                    LwPolyline line8 = new LwPolyline();
                    line8.Vertexes.Add(new LwPolylineVertex(v48));
                    line8.Vertexes.Add(new LwPolylineVertex(v47));
                    line8.Vertexes.Add(new LwPolylineVertex(v46));
                    line8.Vertexes.Add(new LwPolylineVertex(v44));
                    line8.Vertexes.Add(new LwPolylineVertex(v43));
                    line8.Vertexes.Add(new LwPolylineVertex(v42));
                    line8.Vertexes.Add(new LwPolylineVertex(v45));
                    line8.Vertexes.Add(new LwPolylineVertex(v42));
                    line8.Vertexes.Add(new LwPolylineVertex(v41));
                    line8.Vertexes[1].Bulge = Math.Tan(-50 * pi / 180 / 4);
                    fun.PolyFill(dxf, line8, 0.2, contour);

                    LwPolyline line4 = new LwPolyline();
                    line4.Vertexes.Add(new LwPolylineVertex(v56));
                    line4.Vertexes.Add(new LwPolylineVertex(v55));
                    line4.Vertexes.Add(new LwPolylineVertex(v54));
                    line4.Vertexes.Add(new LwPolylineVertex(v61));
                    line4.Vertexes.Add(new LwPolylineVertex(v60));
                    line4.Vertexes.Add(new LwPolylineVertex(v59));
                    line4.Vertexes.Add(new LwPolylineVertex(v58));
                    line4.Vertexes.Add(new LwPolylineVertex(v57));
                    line4.Vertexes[1].Bulge = Math.Tan(-180 * pi / 180 / 4);
                    line4.Vertexes[5].Bulge = Math.Tan(180 * pi / 180 / 4);
                    fun.PolyFill(dxf, line4, 0.2, contour);

                    //标注

                    double height = 5;
                    double arrowsize = 1;
                    double exline = 2;

                    fun.dimrot1(dxf, v5, v8, 90, d1 / 2 + 10, 1, height, arrowsize, exline, "d1=" + d1, "", "");

                    fun.dimrot1(dxf, v28, v22, 90, d1 / 2 + 20, 1, height, arrowsize, exline, "d=" + d, "", "");

                    fun.dimrot1(dxf, v22, v35, 180, d1 / 2 +10, 1, height, arrowsize, exline, "l=" + l, "", "");

                    fun.dimrot1(dxf, v22, v44, 180, d1 / 2 +20, 1, height, arrowsize, exline, "L=" + oal, "", "");

                    fun.dimrot1(dxf, v42, v47, -90, l3 + 10, 1, height, arrowsize, exline, "d2=" + d2, "", "");


                }
            }
            if (z == 3)
            {
                Vector2 v1 = new Vector2(0, 0);
                Vector2 v2 = new Vector2(v1.X + oal + 6 + d1, v1.Y);
                Vector2 v3 = new Vector2(v1.X + 3, v1.Y);
                Vector2 v4 = new Vector2(v3.X, v3.Y + d1 * 3.4 / 10.41);
                Vector2 v5 = new Vector2(v3.X + d1 * 3.4 / 10.41 / 2, v3.Y + d1 / 2);
                Vector2 v6 = new Vector2(v3.X + d1 / 2, v5.Y);
                Vector2 v7 = new Vector2(v6.X, v6.Y * -1);
                Vector2 v8 = new Vector2(v5.X, v5.Y * -1);
                Vector2 v9 = new Vector2(v4.X, v4.Y * -1);
                Vector2 v10 = new Vector2(v3.X, v3.Y + d1 * 3.4 / 10.41 * 1 / 3);
                Vector2 v11 = new Vector2(v5.X, v10.Y + (v5.Y - v4.Y));
                Vector2 v12 = new Vector2(v6.X, v11.Y);
                Vector2 v13 = new Vector2(v12.X, v12.Y * -1);
                Vector2 v14 = new Vector2(v11.X, v11.Y * -1);
                Vector2 v15 = new Vector2(v3.X, v10.Y * -1);
                Vector2 v16 = new Vector2(v3.X + d1 + d1 * 1.21 / 9.24, v12.Y);
                Vector2 v17 = new Vector2(v16.X, v3.Y + d * 7.73 / 19);
                Vector2 v18 = new Vector2(v3.X + l + d1 - l * 1.75 / 36.3, v17.Y);
                Vector2 v19 = new Vector2(v18.X, v18.Y * -1);
                Vector2 v20 = new Vector2(v16.X + l * 5.24 / 36.3, v19.Y);
                Vector2 v21 = new Vector2(v20.X, v3.Y - d / 2);
                Vector2 v22 = new Vector2(v3.X + d1, v21.Y);
                Vector2 v23 = new Vector2(v22.X, v22.Y + d * 4.95 / 19);
                Vector2 v24 = new Vector2(v21.X, v23.Y);
                Vector2 v25 = new Vector2(v16.X, v24.Y);
                Vector2 a26 = new Vector2(v25.X, v25.Y + d * 1.84 / 19);
                Vector2 v26 = new Vector2(v16.X, v13.Y);
                Vector2 v31 = new Vector2(v26.X + l * 21.14 / 36.3, a26.Y);
                Vector2 v32 = new Vector2(v31.X + l * 7.11 / 36.3, v20.Y);
                Vector2 v27 = new Vector2(v23.X, v3.Y + d * 3.61 / 19);
                Vector2 a27 = new Vector2(v16.X, v27.Y);
                Vector2 v28 = new Vector2(v27.X, v27.Y + d * 2.32 / 19);
                Vector2 v29 = new Vector2(v20.X, v28.Y);
                Vector2 v30 = new Vector2(v29.X, v27.Y + d * 2.32 / 19 / 2);
                Vector2 a1 = new Vector2(v16.X, v30.Y);
                Vector2 a2 = new Vector2(a1.X + l * 27.58 / 36.3, a1.Y);
                Vector2 a3 = new Vector2(v32.X, a2.Y + (v17.Y - a2.Y) * 2.32 / 3.03);
                Vector2 a5 = new Vector2(a2.X, v17.Y);
                Vector2 a4 = new Vector2(a3.X - (a3.X - a5.X) * 0.24 / 0.75, a3.Y + (a5.Y - a3.Y) * 0.5 / 0.72);
                Vector2 a6 = new Vector2(v17.X, v28.Y);

                //作图
                Line line1 = new Line(v1, v2);
                line1.Layer = centre;
                line1.Linetype = Linetype.DashDot;
                line1.LinetypeScale = 3;
                dxf.AddEntity(line1);

                double a = v27.Y - v3.Y;
                double b1 = v16.Y - v3.Y;
                if (a >= b1)
                {
                    LwPolyline line2 = new LwPolyline();
                    line2.Vertexes.Add(new LwPolylineVertex(v5));
                    line2.Vertexes.Add(new LwPolylineVertex(v6));
                    line2.Vertexes.Add(new LwPolylineVertex(v7));
                    line2.Vertexes.Add(new LwPolylineVertex(v8));
                    line2.Vertexes.Add(new LwPolylineVertex(v9));
                    line2.Vertexes.Add(new LwPolylineVertex(v4));
                    line2.Vertexes.Add(new LwPolylineVertex(v5));
                    line2.Vertexes.Add(new LwPolylineVertex(v11));
                    line2.Vertexes.Add(new LwPolylineVertex(v10));
                    line2.Vertexes.Add(new LwPolylineVertex(v11));
                    line2.Vertexes.Add(new LwPolylineVertex(v16));
                    line2.Vertexes.Add(new LwPolylineVertex(v26));
                    line2.Vertexes.Add(new LwPolylineVertex(v14));
                    line2.Vertexes.Add(new LwPolylineVertex(v15));
                    line2.Vertexes.Add(new LwPolylineVertex(v14));
                    line2.Vertexes.Add(new LwPolylineVertex(v8));
                    fun.PolyFill(dxf, line2, 0.2, contour);
                }
                else
                {
                    Vector2 a16 = new Vector2(v27.X, v12.Y);
                    LwPolyline line2 = new LwPolyline();
                    line2.Vertexes.Add(new LwPolylineVertex(v5));
                    line2.Vertexes.Add(new LwPolylineVertex(v6));
                    line2.Vertexes.Add(new LwPolylineVertex(v7));
                    line2.Vertexes.Add(new LwPolylineVertex(v8));
                    line2.Vertexes.Add(new LwPolylineVertex(v9));
                    line2.Vertexes.Add(new LwPolylineVertex(v4));
                    line2.Vertexes.Add(new LwPolylineVertex(v5));
                    line2.Vertexes.Add(new LwPolylineVertex(v11));
                    line2.Vertexes.Add(new LwPolylineVertex(v10));
                    line2.Vertexes.Add(new LwPolylineVertex(v11));
                    line2.Vertexes.Add(new LwPolylineVertex(a16));
                    line2.Vertexes.Add(new LwPolylineVertex(v27));
                    line2.Vertexes.Add(new LwPolylineVertex(a27));
                    line2.Vertexes.Add(new LwPolylineVertex(v26));
                    line2.Vertexes.Add(new LwPolylineVertex(v14));
                    line2.Vertexes.Add(new LwPolylineVertex(v15));
                    line2.Vertexes.Add(new LwPolylineVertex(v14));
                    line2.Vertexes.Add(new LwPolylineVertex(v8));
                    fun.PolyFill(dxf, line2, 0.2, contour);

                }

                LwPolyline line3 = new LwPolyline();
                line3.Vertexes.Add(new LwPolylineVertex(v25));
                line3.Vertexes.Add(new LwPolylineVertex(v24));
                line3.Vertexes.Add(new LwPolylineVertex(v21));
                line3.Vertexes.Add(new LwPolylineVertex(v22));
                line3.Vertexes.Add(new LwPolylineVertex(v23));
                line3.Vertexes.Add(new LwPolylineVertex(v25));
                line3.Vertexes.Add(new LwPolylineVertex(a1));
                line3.Vertexes.Add(new LwPolylineVertex(a2));
                line3.Vertexes.Add(new LwPolylineVertex(a3));
                fun.PolyFill(dxf, line3, 0.2, contour);

                LwPolyline line4 = new LwPolyline();
                line4.Vertexes.Add(new LwPolylineVertex(a27));
                line4.Vertexes.Add(new LwPolylineVertex(v27));
                line4.Vertexes.Add(new LwPolylineVertex(v28));
                line4.Vertexes.Add(new LwPolylineVertex(v29));
                line4.Vertexes.Add(new LwPolylineVertex(v30));
                fun.PolyFill(dxf, line4, 0.2, contour);

                LwPolyline line5 = new LwPolyline();
                line5.Vertexes.Add(new LwPolylineVertex(a26));
                line5.Vertexes.Add(new LwPolylineVertex(v31));
                line5.Vertexes.Add(new LwPolylineVertex(v32));
                line5.Vertexes[1].Bulge = Math.Tan(-64 * pi / 180 / 4);
                fun.PolyFill(dxf, line5, 0.2, contour);

                LwPolyline line6 = new LwPolyline();
                line6.Vertexes.Add(new LwPolylineVertex(a6));
                line6.Vertexes.Add(new LwPolylineVertex(v17));
                line6.Vertexes.Add(new LwPolylineVertex(v18));
                line6.Vertexes.Add(new LwPolylineVertex(v19));
                line6.Vertexes.Add(new LwPolylineVertex(v20));
                fun.PolyFill(dxf, line6, 0.2, contour);


                Arc c1 = fun.DrawArc3(a3, a4, a5);
                fun.drawBArc(dxf, c1, 0.2, contour);
                //柄部
                if (bbxz == "削平型直柄")
                {
                    double l1 = 0;
                    double l2 = 0;
                    double l3 = 0;
                    double l4 = 0;
                    double h = 0;
                    if (d2 == 12)
                    {
                        l1 = 45;
                        l2 = 22.5;
                        l3 = 8;
                        h = 10.4;
                    }
                    if (d2 == 16)
                    {
                        l1 = 48;
                        l2 = 24;
                        l3 = 10;
                        h = 14.2;
                    }
                    if (d2 == 20)
                    {
                        l1 = 50;
                        l2 = 25;
                        l3 = 11;
                        h = 18.2;
                    }
                    if (d2 == 25)
                    {
                        l1 = 56;
                        l2 = 32;
                        l3 = 12;
                        l4 = 17;
                        h = 23;
                    }
                    if (d2 == 32)
                    {
                        l1 = 60;
                        l2 = 36;
                        l3 = 14;
                        l4 = 19;
                        h = 30;
                    }
                    if (d2 == 40)
                    {
                        l1 = 70;
                        l2 = 40;
                        l3 = 14;
                        l4 = 19;
                        h = 38;
                    }
                    if (d2 == 50)
                    {
                        l1 = 80;
                        l2 = 45;
                        l3 = 18;
                        l4 = 23;
                        h = 47.8;
                    }

                    Vector2 v33 = new Vector2(v3.X + d1 + l, v3.Y + d2 * 4.92 / 12);
                    Vector2 v35 = new Vector2(v33.X, v33.Y * -1);
                    Vector2 v34 = new Vector2(v33.X + (oal - l1 - l), v33.Y);
                    Vector2 v36 = new Vector2(v34.X, v34.Y * -1);
                    Vector2 v37 = new Vector2(v34.X, v3.Y + d2 / 2);
                    Vector2 v43 = new Vector2(v3.X + d1 + oal, v3.Y + d2 * 4.11 / 12);
                    Vector2 v42 = new Vector2(v43.X - l1 * 1.93 / 36.76, v3.Y + d2 / 2);
                    Vector2 v41 = new Vector2(v43.X - l2 + l3 / 2 + (d2 - h), v42.Y);
                    Vector2 v44 = new Vector2(v43.X, v43.Y * -1);
                    Vector2 v45 = new Vector2(v42.X, v42.Y * -1);
                    Vector2 v46 = new Vector2(v43.X - l1, v45.Y);
                    Vector2 v40 = new Vector2(v43.X - l2 + l3 / 2, v45.Y + h);
                    Vector2 v39 = new Vector2(v40.X - l3, v40.Y);
                    Vector2 v38 = new Vector2(v39.X - (d2 - h), v41.Y);
                    Vector2 a10 = new Vector2(v44.X, v45.Y + h);
                    Vector2 a20 = new Vector2(v45.X, a1.Y);
                    Vector2 a30 = new Vector2(a1.X - l4, a1.Y);
                    Vector2 a40 = new Vector2(a3.X - (d2 - h), v41.Y);
                    if (d2 <= 20)
                    {
                        LwPolyline line7 = new LwPolyline();
                        line7.Vertexes.Add(new LwPolylineVertex(v42));
                        line7.Vertexes.Add(new LwPolylineVertex(v45));
                        line7.Vertexes.Add(new LwPolylineVertex(v44));
                        line7.Vertexes.Add(new LwPolylineVertex(v43));
                        line7.Vertexes.Add(new LwPolylineVertex(v42));
                        line7.Vertexes.Add(new LwPolylineVertex(v41));
                        line7.Vertexes.Add(new LwPolylineVertex(v40));
                        line7.Vertexes.Add(new LwPolylineVertex(v39));
                        line7.Vertexes.Add(new LwPolylineVertex(v38));
                        line7.Vertexes.Add(new LwPolylineVertex(v37));
                        line7.Vertexes.Add(new LwPolylineVertex(v36));
                        line7.Vertexes.Add(new LwPolylineVertex(v46));
                        line7.Vertexes.Add(new LwPolylineVertex(v45));
                        fun.PolyFill(dxf, line7, 0.2, contour);

                    }
                    if (d2 > 20)
                    {
                        LwPolyline line7 = new LwPolyline();
                        line7.Vertexes.Add(new LwPolylineVertex(a20));
                        line7.Vertexes.Add(new LwPolylineVertex(v45));
                        line7.Vertexes.Add(new LwPolylineVertex(v44));
                        line7.Vertexes.Add(new LwPolylineVertex(a10));
                        line7.Vertexes.Add(new LwPolylineVertex(a30));
                        line7.Vertexes.Add(new LwPolylineVertex(a40));
                        line7.Vertexes.Add(new LwPolylineVertex(v41));
                        line7.Vertexes.Add(new LwPolylineVertex(v40));
                        line7.Vertexes.Add(new LwPolylineVertex(v39));
                        line7.Vertexes.Add(new LwPolylineVertex(v38));
                        line7.Vertexes.Add(new LwPolylineVertex(v37));
                        line7.Vertexes.Add(new LwPolylineVertex(v36));
                        line7.Vertexes.Add(new LwPolylineVertex(v46));
                        line7.Vertexes.Add(new LwPolylineVertex(v45));
                        fun.PolyFill(dxf, line7, 0.2, contour);

                    }
                    LwPolyline line8 = new LwPolyline();
                    line8.Vertexes.Add(new LwPolylineVertex(v33));
                    line8.Vertexes.Add(new LwPolylineVertex(v35));
                    line8.Vertexes.Add(new LwPolylineVertex(v36));
                    line8.Vertexes.Add(new LwPolylineVertex(v34));
                    line8.Vertexes.Add(new LwPolylineVertex(v33));
                    line8.Vertexes.Add(new LwPolylineVertex(v18));
                    line8.Vertexes.Add(new LwPolylineVertex(v19));
                    line8.Vertexes.Add(new LwPolylineVertex(v35));
                    fun.PolyFill(dxf, line8, 0.2, contour);

                    //标注

                    double height = 5;
                    double arrowsize = 1;
                    double exline = 2;

                    fun.dimrot1(dxf, v5, v8, 90, d1 / 2 +10, 1, height, arrowsize, exline, "d1=" + d1, "", "");

                    fun.dimrot1(dxf, new Vector2 (v22.X ,v22.Y *-1), v22, 90, d1 / 2 +20, 1, height, arrowsize, exline, "d=" + d, "", "");

                    fun.dimrot1(dxf, v22, v35, 180, d1 / 2 + 10, 1, height, arrowsize, exline, "l=" + l, "", "");

                    fun.dimrot1(dxf, v22, v44, 180, d1 /2 +20, 1, height, arrowsize, exline, "L=" + oal, "", "");
                    if (d2 <= 20)
                    {
                        fun.dimrot1(dxf, v42, v45, -90, d1 / 2 +10, 1, height, arrowsize, exline, "d2=" + d2, "", "");
                    }
                    if (d2 > 20)
                    {
                        fun.dimrot1(dxf, a40, v45, -90, d1/2 +20, 1, height, arrowsize, exline, "d2=" + d2, "", "");
                    }


                }
                if (bbxz == "莫氏锥柄")
                {
                    double db = 0;
                    double ds = 0;
                    double tg = 0;
                    double b = 0;
                    double e = 0;
                    if (czc == 2)
                    {
                        db = 17.78;
                        ds = 14.6;
                        tg = 0.04995;
                        b = 6.3;
                        e = 16;
                    }
                    if (czc == 3)
                    {
                        db = 23.825;
                        ds = 19.8;
                        tg = 0.05020;
                        b = 7.9;
                        e = 20;
                    }
                    if (czc == 4)
                    {
                        db = 31.267;
                        ds = 25.9;
                        tg = 0.05194;
                        b = 11.9;
                        e = 24;
                    }
                    double l3 = (db - ds) / tg;
                    Vector2 v33 = new Vector2(v3.X + d1 + l, v3.Y + db * 6.7 / 8.16 / 2);
                    Vector2 v35 = new Vector2(v33.X, v33.Y * -1);
                    Vector2 v34 = new Vector2(v33.X + oal - l3 - e - l, v33.Y);
                    Vector2 v36 = new Vector2(v34.X, v35.Y);
                    Vector2 v37 = new Vector2(v34.X, v3.Y + db / 2);
                    Vector2 v38 = new Vector2(v37.X + l3, v3.Y + ds / 2);
                    Vector2 v39 = new Vector2(v38.X + e * 4.52 / 7.75, v3.Y + b / 2);
                    Vector2 v40 = new Vector2(v38.X + e, v39.Y);
                    Vector2 v41 = new Vector2(v40.X, v40.Y * -1);
                    Vector2 v42 = new Vector2(v39.X, v39.Y * -1);
                    Vector2 v43 = new Vector2(v38.X, v38.Y * -1);
                    Vector2 v44 = new Vector2(v37.X, v37.Y * -1);

                    LwPolyline line8 = new LwPolyline();
                    line8.Vertexes.Add(new LwPolylineVertex(v39));
                    line8.Vertexes.Add(new LwPolylineVertex(v42));
                    line8.Vertexes.Add(new LwPolylineVertex(v41));
                    line8.Vertexes.Add(new LwPolylineVertex(v40));
                    line8.Vertexes.Add(new LwPolylineVertex(v39));
                    line8.Vertexes.Add(new LwPolylineVertex(v38));
                    line8.Vertexes.Add(new LwPolylineVertex(v37));
                    line8.Vertexes.Add(new LwPolylineVertex(v44));
                    line8.Vertexes.Add(new LwPolylineVertex(v43));
                    line8.Vertexes.Add(new LwPolylineVertex(v42));
                    line8.Vertexes[4].Bulge = Math.Tan(-39 * pi / 180 / 4);
                    line8.Vertexes[8].Bulge = Math.Tan(-39 * pi / 180 / 4);
                    fun.PolyFill(dxf, line8, 0.2, contour);

                    LwPolyline line7 = new LwPolyline();
                    line7.Vertexes.Add(new LwPolylineVertex(v33));
                    line7.Vertexes.Add(new LwPolylineVertex(v35));
                    line7.Vertexes.Add(new LwPolylineVertex(v36));
                    line7.Vertexes.Add(new LwPolylineVertex(v34));
                    line7.Vertexes.Add(new LwPolylineVertex(v33));
                    line7.Vertexes.Add(new LwPolylineVertex(v18));
                    line7.Vertexes.Add(new LwPolylineVertex(v19));
                    line7.Vertexes.Add(new LwPolylineVertex(v35));
                    fun.PolyFill(dxf, line7, 0.2, contour);

                    //标注

                    double height = 5;
                    double arrowsize = 1;
                    double exline = 2;

                    fun.dimrot1(dxf, v5, v8, 90, d1 / 2 +10, 1, height, arrowsize, exline, "d1=" + d1, "", "");

                    fun.dimrot1(dxf, v28, v22, 90, d1 / 2 +20, 1, height, arrowsize, exline, "d=" + d, "", "");

                    fun.dimrot1(dxf, v22, v35, 180, d1 / 2 +10, 1, height, arrowsize, exline, "l=" + l, "", "");

                    fun.dimrot1(dxf, v22, v41, 180, d1 / 2 +20, 1, height, arrowsize, exline, "L=" + oal, "", "");


                }
                if (bbxz == "圆柱销快换柄")
                {
                    double L1 = 0;
                    double l1 = 0;
                    double l2 = 0;
                    double l3 = 0;
                    double d3 = 0;
                    double c = 0;
                    double h = 0;
                    if (d2 == 22)
                    {
                        L1 = 42;
                        l1 = 14;
                        l2 = 10.5;
                        l3 = 22.5;
                        d3 = 20;
                        c = 7.5;
                        h = 19;
                    }
                    if (d2 == 40)
                    {
                        L1 = 55;
                        l1 = 22;
                        l2 = 15.5;
                        l3 = 30.5;
                        d3 = 38;
                        c = 13;
                        h = 35;
                    }
                    Vector2 v33 = new Vector2(v3.X + d1 + l, v3.Y + d2 * 5.89 / 14.2);
                    Vector2 v35 = new Vector2(v33.X, v33.Y * -1);
                    Vector2 v34 = new Vector2(v33.X + oal - l - L1, v33.Y);
                    Vector2 v36 = new Vector2(v34.X, v35.Y);
                    Vector2 v37 = new Vector2(v34.X, v3.Y + d2 / 2);
                    Vector2 v38 = new Vector2(v37.X + l2 - (d2 - d3) / 2, v37.Y);
                    Vector2 v39 = new Vector2(v37.X + l2, v3.Y + d3 / 2);
                    Vector2 v40 = new Vector2(v39.X + (L1 - l2 - l3), v39.Y);
                    Vector2 v41 = new Vector2(v40.X + (d2 - d3) / 2, v38.Y);
                    Vector2 v42 = new Vector2(v34.X + L1 - L1 * 1.85 / 40.09, v41.Y);
                    Vector2 v43 = new Vector2(v34.X + L1, v3.Y + d2 * 4.1 / 14.2);
                    Vector2 v44 = new Vector2(v43.X, v42.Y - h);
                    Vector2 v45 = new Vector2(v42.X, v44.Y);
                    Vector2 v46 = new Vector2(v44.X - l3 * 13.28 / 24.14, v45.Y);
                    Vector2 v47 = new Vector2(v44.X - l1, v41.Y * -1);
                    Vector2 v48 = new Vector2(v41.X, v47.Y);
                    Vector2 v49 = new Vector2(v40.X, v40.Y * -1);
                    Vector2 v50 = new Vector2(v39.X, v39.Y * -1);
                    Vector2 v51 = new Vector2(v38.X, v38.Y * -1);
                    Vector2 v52 = new Vector2(v37.X, v37.Y * -1);
                    Vector2 v53 = new Vector2(v44.X - c, v3.Y);
                    Vector2 v56 = new Vector2(v53.X - l1 * 3.58 / 18, v45.Y);
                    Vector2 v55 = new Vector2(v56.X, v3.Y);
                    Vector2 v54 = new Vector2(v53.X + l1 * 3.58 / 18, v55.Y);
                    Vector2 v61 = new Vector2(v54.X, v45.Y);
                    Vector2 v57 = new Vector2(v53.X - l1 * 2.24 / 18, v45.Y);
                    Vector2 v58 = new Vector2(v57.X, v3.Y);
                    Vector2 v59 = new Vector2(v53.X + l1 * 2.24 / 18, v53.Y);
                    Vector2 v60 = new Vector2(v59.X, v45.Y);

                    LwPolyline line7 = new LwPolyline();
                    line7.Vertexes.Add(new LwPolylineVertex(v38));
                    line7.Vertexes.Add(new LwPolylineVertex(v51));
                    line7.Vertexes.Add(new LwPolylineVertex(v52));
                    line7.Vertexes.Add(new LwPolylineVertex(v37));
                    line7.Vertexes.Add(new LwPolylineVertex(v38));
                    line7.Vertexes.Add(new LwPolylineVertex(v39));
                    line7.Vertexes.Add(new LwPolylineVertex(v50));
                    line7.Vertexes.Add(new LwPolylineVertex(v51));
                    line7.Vertexes.Add(new LwPolylineVertex(v50));
                    line7.Vertexes.Add(new LwPolylineVertex(v49));
                    line7.Vertexes.Add(new LwPolylineVertex(v40));
                    line7.Vertexes.Add(new LwPolylineVertex(v39));
                    line7.Vertexes.Add(new LwPolylineVertex(v40));
                    line7.Vertexes.Add(new LwPolylineVertex(v41));
                    line7.Vertexes.Add(new LwPolylineVertex(v48));
                    line7.Vertexes.Add(new LwPolylineVertex(v49));
                    fun.PolyFill(dxf, line7, 0.2, contour);

                    LwPolyline line9 = new LwPolyline();
                    line9.Vertexes.Add(new LwPolylineVertex(v33));
                    line9.Vertexes.Add(new LwPolylineVertex(v35));
                    line9.Vertexes.Add(new LwPolylineVertex(v36));
                    line9.Vertexes.Add(new LwPolylineVertex(v34));
                    line9.Vertexes.Add(new LwPolylineVertex(v33));
                    line9.Vertexes.Add(new LwPolylineVertex(v18));
                    line9.Vertexes.Add(new LwPolylineVertex(v19));
                    line9.Vertexes.Add(new LwPolylineVertex(v35));
                    fun.PolyFill(dxf, line9, 0.2, contour);

                    LwPolyline line8 = new LwPolyline();
                    line8.Vertexes.Add(new LwPolylineVertex(v48));
                    line8.Vertexes.Add(new LwPolylineVertex(v47));
                    line8.Vertexes.Add(new LwPolylineVertex(v46));
                    line8.Vertexes.Add(new LwPolylineVertex(v44));
                    line8.Vertexes.Add(new LwPolylineVertex(v43));
                    line8.Vertexes.Add(new LwPolylineVertex(v42));
                    line8.Vertexes.Add(new LwPolylineVertex(v45));
                    line8.Vertexes.Add(new LwPolylineVertex(v42));
                    line8.Vertexes.Add(new LwPolylineVertex(v41));
                    line8.Vertexes[1].Bulge = Math.Tan(-50 * pi / 180 / 4);
                    fun.PolyFill(dxf, line8, 0.2, contour);

                    LwPolyline line10 = new LwPolyline();
                    line10.Vertexes.Add(new LwPolylineVertex(v56));
                    line10.Vertexes.Add(new LwPolylineVertex(v55));
                    line10.Vertexes.Add(new LwPolylineVertex(v54));
                    line10.Vertexes.Add(new LwPolylineVertex(v61));
                    line10.Vertexes.Add(new LwPolylineVertex(v60));
                    line10.Vertexes.Add(new LwPolylineVertex(v59));
                    line10.Vertexes.Add(new LwPolylineVertex(v58));
                    line10.Vertexes.Add(new LwPolylineVertex(v57));
                    line10.Vertexes[1].Bulge = Math.Tan(-180 * pi / 180 / 4);
                    line10.Vertexes[5].Bulge = Math.Tan(180 * pi / 180 / 4);
                    fun.PolyFill(dxf, line10, 0.2, contour);

                    //标注

                    double height = 5;
                    double arrowsize = 1;
                    double exline = 2;

                    fun.dimrot1(dxf, v5, v8, 90, d1 / 2 + 10, 1, height, arrowsize, exline, "d1=" + d1, "", "");

                    fun.dimrot1(dxf, v28, v22, 90, d1 / 2 + 20, 1, height, arrowsize, exline, "d=" + d, "", "");

                    fun.dimrot1(dxf, v22, v35, 180, d1 / 2 + 10, 1, height, arrowsize, exline, "l=" + l, "", "");

                    fun.dimrot1(dxf, v22, v41, 180, d1 / 2 + 20, 1, height, arrowsize, exline, "L=" + oal, "", "");

                    fun.dimrot1(dxf, v42, v47, -90, l3 +10, 1, height, arrowsize, exline, "d2=" + d2, "", "");


                }
            }
            if (z == 4)
            {
                Vector2 v1 = new Vector2(0, 0);
                Vector2 v2 = new Vector2(v1.X + oal + 6 + d1, v1.Y);
                Vector2 v3 = new Vector2(v1.X + 3, v1.Y);
                Vector2 v4 = new Vector2(v3.X, v3.Y + d1 * 3.4 / 10.41);
                Vector2 v5 = new Vector2(v3.X + d1 * 3.4 / 10.41 / 2, v3.Y + d1 / 2);
                Vector2 v6 = new Vector2(v3.X + d1 / 2, v5.Y);
                Vector2 v7 = new Vector2(v6.X, v6.Y * -1);
                Vector2 v8 = new Vector2(v5.X, v5.Y * -1);
                Vector2 v9 = new Vector2(v4.X, v4.Y * -1);
                Vector2 v10 = new Vector2(v3.X, v3.Y + d1 * 3.4 / 10.41 * 1 / 3);
                Vector2 v11 = new Vector2(v5.X, v10.Y + (v5.Y - v4.Y));
                Vector2 v12 = new Vector2(v6.X, v11.Y);
                Vector2 v13 = new Vector2(v12.X, v12.Y * -1);
                Vector2 v14 = new Vector2(v11.X, v11.Y * -1);
                Vector2 v15 = new Vector2(v3.X, v10.Y * -1);
                Vector2 v16 = new Vector2(v3.X + d1 + d1 * 1.21 / 9.24, v12.Y);
                Vector2 v17 = new Vector2(v16.X, v3.Y + d * 7.73 / 19);
                Vector2 v18 = new Vector2(v3.X + l + d1 - l * 1.75 / 36.3, v17.Y);
                Vector2 v19 = new Vector2(v18.X, v18.Y * -1);
                Vector2 v20 = new Vector2(v16.X + l * 5.24 / 36.3, v19.Y);
                Vector2 v21 = new Vector2(v20.X, v3.Y - d / 2);
                Vector2 v22 = new Vector2(v3.X + d1, v21.Y);
                Vector2 v23 = new Vector2(v22.X, v22.Y + d * 4.95 / 19);
                Vector2 v24 = new Vector2(v21.X, v23.Y);
                Vector2 v25 = new Vector2(v16.X, v24.Y);
                Vector2 a26 = new Vector2(v25.X, v25.Y + d * 1.84 / 19);
                Vector2 v26 = new Vector2(v16.X, v13.Y);
                Vector2 v27 = new Vector2(v23.X, v23.Y * -1);
                Vector2 a27 = new Vector2(v16.X, v27.Y);
                Vector2 v28 = new Vector2(v27.X, v22.Y * -1);
                Vector2 v29 = new Vector2(v20.X, v28.Y);
                Vector2 v30 = new Vector2(v29.X, v17.Y);
                Vector2 v31 = new Vector2(v26.X + l * 21.14 / 36.3, a26.Y);
                Vector2 v32 = new Vector2(v31.X + l * 7.11 / 36.3, v20.Y);
                Vector2 a1 = new Vector2(v23.X, v3.Y + d * 0.91 / 19);
                Vector2 a2 = new Vector2(a1.X, a1.Y + d * 1.31 / 19);
                Vector2 a3 = new Vector2(v24.X, a2.Y);
                Vector2 a4 = new Vector2(a3.X, a1.Y);
                Vector2 a5 = new Vector2(v25.X, a1.Y);
                Vector2 a6 = new Vector2(a5.X, a2.Y);
                Vector2 a7 = new Vector2(v32.X, a4.Y + (a3.Y - a4.Y) / 2);
                Vector2 a8 = new Vector2(v31.X, v3.Y + d * 6.3 / 19);
                Vector2 a9 = new Vector2(v17.X, a8.Y);
                Vector2 a10 = new Vector2(a8.X, a7.Y);
                Vector2 a11 = new Vector2(a3.X, a7.Y);

                //作图
                Line line1 = new Line(v1, v2);
                line1.Layer = centre;
                line1.Linetype = Linetype.DashDot;
                line1.LinetypeScale = 3;
                dxf.AddEntity(line1);

                double a = v2.Y - v3.Y;
                double b1 = v16.Y - v3.Y;
                if (a <= b1)
                {
                    LwPolyline line2 = new LwPolyline();
                    line2.Vertexes.Add(new LwPolylineVertex(v5));
                    line2.Vertexes.Add(new LwPolylineVertex(v6));
                    line2.Vertexes.Add(new LwPolylineVertex(v7));
                    line2.Vertexes.Add(new LwPolylineVertex(v8));
                    line2.Vertexes.Add(new LwPolylineVertex(v9));
                    line2.Vertexes.Add(new LwPolylineVertex(v4));
                    line2.Vertexes.Add(new LwPolylineVertex(v5));
                    line2.Vertexes.Add(new LwPolylineVertex(v11));
                    line2.Vertexes.Add(new LwPolylineVertex(v10));
                    line2.Vertexes.Add(new LwPolylineVertex(v11));
                    line2.Vertexes.Add(new LwPolylineVertex(v16));
                    line2.Vertexes.Add(new LwPolylineVertex(a6));
                    line2.Vertexes.Add(new LwPolylineVertex(a2));
                    line2.Vertexes.Add(new LwPolylineVertex(a1));
                    line2.Vertexes.Add(new LwPolylineVertex(a5));
                    line2.Vertexes.Add(new LwPolylineVertex(v26));
                    line2.Vertexes.Add(new LwPolylineVertex(v14));
                    line2.Vertexes.Add(new LwPolylineVertex(v15));
                    line2.Vertexes.Add(new LwPolylineVertex(v14));
                    line2.Vertexes.Add(new LwPolylineVertex(v8));
                    fun.PolyFill(dxf, line2, 0.2, contour);
                }
                else
                {
                    Vector2 a16 = new Vector2(a1.X, v12.Y);
                    LwPolyline line2 = new LwPolyline();
                    line2.Vertexes.Add(new LwPolylineVertex(v5));
                    line2.Vertexes.Add(new LwPolylineVertex(v6));
                    line2.Vertexes.Add(new LwPolylineVertex(v7));
                    line2.Vertexes.Add(new LwPolylineVertex(v8));
                    line2.Vertexes.Add(new LwPolylineVertex(v9));
                    line2.Vertexes.Add(new LwPolylineVertex(v4));
                    line2.Vertexes.Add(new LwPolylineVertex(v5));
                    line2.Vertexes.Add(new LwPolylineVertex(v11));
                    line2.Vertexes.Add(new LwPolylineVertex(v10));
                    line2.Vertexes.Add(new LwPolylineVertex(v11));
                    line2.Vertexes.Add(new LwPolylineVertex(a16));
                    line2.Vertexes.Add(new LwPolylineVertex(a1));
                    line2.Vertexes.Add(new LwPolylineVertex(a5));
                    line2.Vertexes.Add(new LwPolylineVertex(v26));
                    line2.Vertexes.Add(new LwPolylineVertex(v14));
                    line2.Vertexes.Add(new LwPolylineVertex(v15));
                    line2.Vertexes.Add(new LwPolylineVertex(v14));
                    line2.Vertexes.Add(new LwPolylineVertex(v8));
                    fun.PolyFill(dxf, line2, 0.2, contour);
                }

                LwPolyline line3 = new LwPolyline();
                line3.Vertexes.Add(new LwPolylineVertex(v25));
                line3.Vertexes.Add(new LwPolylineVertex(v24));
                line3.Vertexes.Add(new LwPolylineVertex(v21));
                line3.Vertexes.Add(new LwPolylineVertex(v22));
                line3.Vertexes.Add(new LwPolylineVertex(v23));
                line3.Vertexes.Add(new LwPolylineVertex(v25));
                line3.Vertexes.Add(new LwPolylineVertex(a5));
                line3.Vertexes.Add(new LwPolylineVertex(a4));
                line3.Vertexes.Add(new LwPolylineVertex(a3));
                line3.Vertexes.Add(new LwPolylineVertex(a6));
                line3.Vertexes.Add(new LwPolylineVertex(v17));
                line3.Vertexes.Add(new LwPolylineVertex(v18));
                line3.Vertexes.Add(new LwPolylineVertex(v19));
                line3.Vertexes.Add(new LwPolylineVertex(v20));
                fun.PolyFill(dxf, line3, 0.2, contour);

                LwPolyline line4 = new LwPolyline();
                line4.Vertexes.Add(new LwPolylineVertex(a27));
                line4.Vertexes.Add(new LwPolylineVertex(v27));
                line4.Vertexes.Add(new LwPolylineVertex(v28));
                line4.Vertexes.Add(new LwPolylineVertex(v29));
                line4.Vertexes.Add(new LwPolylineVertex(v30));
                fun.PolyFill(dxf, line4, 0.2, contour);

                LwPolyline line5 = new LwPolyline();
                line5.Vertexes.Add(new LwPolylineVertex(a26));
                line5.Vertexes.Add(new LwPolylineVertex(v31));
                line5.Vertexes.Add(new LwPolylineVertex(v32));
                line5.Vertexes[1].Bulge = Math.Tan(-64 * pi / 180 / 4);
                fun.PolyFill(dxf, line5, 0.2, contour);

                LwPolyline line6 = new LwPolyline();
                line6.Vertexes.Add(new LwPolylineVertex(a11));
                line6.Vertexes.Add(new LwPolylineVertex(a7));
                line6.Vertexes.Add(new LwPolylineVertex(a8));
                line6.Vertexes.Add(new LwPolylineVertex(a10));
                line6.Vertexes.Add(new LwPolylineVertex(a8));
                line6.Vertexes.Add(new LwPolylineVertex(a9));
                line6.Vertexes[1].Bulge = Math.Tan(57 * pi / 180 / 4);
                fun.PolyFill(dxf, line6, 0.2, contour);
                //柄部
                if (bbxz == "削平型直柄")
                {
                    double l1 = 0;
                    double l2 = 0;
                    double l3 = 0;
                    double l4 = 0;
                    double h = 0;
                    if (d2 == 12)
                    {
                        l1 = 45;
                        l2 = 22.5;
                        l3 = 8;
                        h = 10.4;
                    }
                    if (d2 == 16)
                    {
                        l1 = 48;
                        l2 = 24;
                        l3 = 10;
                        h = 14.2;
                    }
                    if (d2 == 20)
                    {
                        l1 = 50;
                        l2 = 25;
                        l3 = 11;
                        h = 18.2;
                    }
                    if (d2 == 25)
                    {
                        l1 = 56;
                        l2 = 32;
                        l3 = 12;
                        l4 = 17;
                        h = 23;
                    }
                    if (d2 == 32)
                    {
                        l1 = 60;
                        l2 = 36;
                        l3 = 14;
                        l4 = 19;
                        h = 30;
                    }
                    if (d2 == 40)
                    {
                        l1 = 70;
                        l2 = 40;
                        l3 = 14;
                        l4 = 19;
                        h = 38;
                    }
                    if (d2 == 50)
                    {
                        l1 = 80;
                        l2 = 45;
                        l3 = 18;
                        l4 = 23;
                        h = 47.8;
                    }

                    Vector2 v33 = new Vector2(v3.X + d1 + l, v3.Y + d2 * 4.92 / 12);
                    Vector2 v35 = new Vector2(v33.X, v33.Y * -1);
                    Vector2 v34 = new Vector2(v33.X + (oal - l1 - l), v33.Y);
                    Vector2 v36 = new Vector2(v34.X, v34.Y * -1);
                    Vector2 v37 = new Vector2(v34.X, v3.Y + d2 / 2);
                    Vector2 v43 = new Vector2(v3.X + d1 + oal, v3.Y + d2 * 4.11 / 12);
                    Vector2 v42 = new Vector2(v43.X - l1 * 1.93 / 36.76, v3.Y + d2 / 2);
                    Vector2 v41 = new Vector2(v43.X - l2 + l3 / 2 + (d2 - h), v42.Y);
                    Vector2 v44 = new Vector2(v43.X, v43.Y * -1);
                    Vector2 v45 = new Vector2(v42.X, v42.Y * -1);
                    Vector2 v46 = new Vector2(v43.X - l1, v45.Y);
                    Vector2 v40 = new Vector2(v43.X - l2 + l3 / 2, v45.Y + h);
                    Vector2 v39 = new Vector2(v40.X - l3, v40.Y);
                    Vector2 v38 = new Vector2(v39.X - (d2 - h), v41.Y);
                    Vector2 a100 = new Vector2(v44.X, v45.Y + h);
                    Vector2 a20 = new Vector2(v45.X, a1.Y);
                    Vector2 a30 = new Vector2(a1.X - l4, a1.Y);
                    Vector2 a40 = new Vector2(a3.X - (d2 - h), v41.Y);
                    if (d2 <= 20)
                    {
                        LwPolyline line7 = new LwPolyline();
                        line7.Vertexes.Add(new LwPolylineVertex(v42));
                        line7.Vertexes.Add(new LwPolylineVertex(v45));
                        line7.Vertexes.Add(new LwPolylineVertex(v44));
                        line7.Vertexes.Add(new LwPolylineVertex(v43));
                        line7.Vertexes.Add(new LwPolylineVertex(v42));
                        line7.Vertexes.Add(new LwPolylineVertex(v41));
                        line7.Vertexes.Add(new LwPolylineVertex(v40));
                        line7.Vertexes.Add(new LwPolylineVertex(v39));
                        line7.Vertexes.Add(new LwPolylineVertex(v38));
                        line7.Vertexes.Add(new LwPolylineVertex(v37));
                        line7.Vertexes.Add(new LwPolylineVertex(v36));
                        line7.Vertexes.Add(new LwPolylineVertex(v46));
                        line7.Vertexes.Add(new LwPolylineVertex(v45));
                        fun.PolyFill(dxf, line7, 0.2, contour);

                    }
                    if (d2 > 20)
                    {
                        LwPolyline line7 = new LwPolyline();
                        line7.Vertexes.Add(new LwPolylineVertex(a20));
                        line7.Vertexes.Add(new LwPolylineVertex(v45));
                        line7.Vertexes.Add(new LwPolylineVertex(v44));
                        line7.Vertexes.Add(new LwPolylineVertex(a100));
                        line7.Vertexes.Add(new LwPolylineVertex(a30));
                        line7.Vertexes.Add(new LwPolylineVertex(a40));
                        line7.Vertexes.Add(new LwPolylineVertex(v41));
                        line7.Vertexes.Add(new LwPolylineVertex(v40));
                        line7.Vertexes.Add(new LwPolylineVertex(v39));
                        line7.Vertexes.Add(new LwPolylineVertex(v38));
                        line7.Vertexes.Add(new LwPolylineVertex(v37));
                        line7.Vertexes.Add(new LwPolylineVertex(v36));
                        line7.Vertexes.Add(new LwPolylineVertex(v46));
                        line7.Vertexes.Add(new LwPolylineVertex(v45));
                        fun.PolyFill(dxf, line7, 0.2, contour);

                    }
                    LwPolyline line8 = new LwPolyline();
                    line8.Vertexes.Add(new LwPolylineVertex(v33));
                    line8.Vertexes.Add(new LwPolylineVertex(v35));
                    line8.Vertexes.Add(new LwPolylineVertex(v36));
                    line8.Vertexes.Add(new LwPolylineVertex(v34));
                    line8.Vertexes.Add(new LwPolylineVertex(v33));
                    line8.Vertexes.Add(new LwPolylineVertex(v18));
                    line8.Vertexes.Add(new LwPolylineVertex(v19));
                    line8.Vertexes.Add(new LwPolylineVertex(v35));
                    fun.PolyFill(dxf, line8, 0.2, contour);

                    //标注

                    double height = 5;
                    double arrowsize = 1;
                    double exline = 2;

                    fun.dimrot1(dxf, v5, v8, 90, d1 / 2 + 10, 1, height, arrowsize, exline, "d1=" + d1, "", "");

                    fun.dimrot1(dxf, v28, v22, 90, d1 / 2 + 20, 1, height, arrowsize, exline, "d=" + d, "", "");

                    fun.dimrot1(dxf, v22, v35, 180, d1 / 2 + 10, 1, height, arrowsize, exline, "l=" + l, "", "");

                    fun.dimrot1(dxf, v22, v41, 180, d1 / 2 + 20, 1, height, arrowsize, exline, "L=" + oal, "", "");
                    if (d2 <= 20)
                    {
                        fun.dimrot1(dxf, v42, v45, -90, d1 / 2, 1, height, arrowsize, exline, "d2=" + d2, "", "");
                    }
                    if (d2 > 20)
                    {
                        fun.dimrot1(dxf, a4, v45, -90, d1, 1, height, arrowsize, exline, "d2=" + d2, "", "");
                    }


                }
                if (bbxz == "莫氏锥柄")
                {
                    double db = 0;
                    double ds = 0;
                    double tg = 0;
                    double b = 0;
                    double e = 0;
                    if (czc == 2)
                    {
                        db = 17.78;
                        ds = 14.6;
                        tg = 0.04995;
                        b = 6.3;
                        e = 16;
                    }
                    if (czc == 3)
                    {
                        db = 23.825;
                        ds = 19.8;
                        tg = 0.05020;
                        b = 7.9;
                        e = 20;
                    }
                    if (czc == 4)
                    {
                        db = 31.267;
                        ds = 25.9;
                        tg = 0.05194;
                        b = 11.9;
                        e = 24;
                    }
                    double l3 = (db - ds) / tg;
                    Vector2 v33 = new Vector2(v3.X + d1 + l, v3.Y + db * 6.7 / 8.16 / 2);
                    Vector2 v35 = new Vector2(v33.X, v33.Y * -1);
                    Vector2 v34 = new Vector2(v33.X + oal - l3 - e - l, v33.Y);
                    Vector2 v36 = new Vector2(v34.X, v35.Y);
                    Vector2 v37 = new Vector2(v34.X, v3.Y + db / 2);
                    Vector2 v38 = new Vector2(v37.X + l3, v3.Y + ds / 2);
                    Vector2 v39 = new Vector2(v38.X + e * 4.52 / 7.75, v3.Y + b / 2);
                    Vector2 v40 = new Vector2(v38.X + e, v39.Y);
                    Vector2 v41 = new Vector2(v40.X, v40.Y * -1);
                    Vector2 v42 = new Vector2(v39.X, v39.Y * -1);
                    Vector2 v43 = new Vector2(v38.X, v38.Y * -1);
                    Vector2 v44 = new Vector2(v37.X, v37.Y * -1);

                    LwPolyline line8 = new LwPolyline();
                    line8.Vertexes.Add(new LwPolylineVertex(v39));
                    line8.Vertexes.Add(new LwPolylineVertex(v42));
                    line8.Vertexes.Add(new LwPolylineVertex(v41));
                    line8.Vertexes.Add(new LwPolylineVertex(v40));
                    line8.Vertexes.Add(new LwPolylineVertex(v39));
                    line8.Vertexes.Add(new LwPolylineVertex(v38));
                    line8.Vertexes.Add(new LwPolylineVertex(v37));
                    line8.Vertexes.Add(new LwPolylineVertex(v44));
                    line8.Vertexes.Add(new LwPolylineVertex(v43));
                    line8.Vertexes.Add(new LwPolylineVertex(v42));
                    line8.Vertexes[4].Bulge = Math.Tan(-39 * pi / 180 / 4);
                    line8.Vertexes[8].Bulge = Math.Tan(-39 * pi / 180 / 4);
                    fun.PolyFill(dxf, line8, 0.2, contour);

                    LwPolyline line7 = new LwPolyline();
                    line7.Vertexes.Add(new LwPolylineVertex(v33));
                    line7.Vertexes.Add(new LwPolylineVertex(v35));
                    line7.Vertexes.Add(new LwPolylineVertex(v36));
                    line7.Vertexes.Add(new LwPolylineVertex(v34));
                    line7.Vertexes.Add(new LwPolylineVertex(v33));
                    line7.Vertexes.Add(new LwPolylineVertex(v18));
                    line7.Vertexes.Add(new LwPolylineVertex(v19));
                    line7.Vertexes.Add(new LwPolylineVertex(v35));
                    fun.PolyFill(dxf, line7, 0.2, contour);

                    //标注

                    double height = 5;
                    double arrowsize = 1;
                    double exline = 2;

                    fun.dimrot1(dxf, v5, v8, 90, d1 / 2 + 10, 1, height, arrowsize, exline, "d1=" + d1, "", "");

                    fun.dimrot1(dxf, v28, v22, 90, d1 / 2 + 20, 1, height, arrowsize, exline, "d=" + d, "", "");

                    fun.dimrot1(dxf, v22, v35, 180, d1 / 2 + 10, 1, height, arrowsize, exline, "l=" + l, "", "");

                    fun.dimrot1(dxf, v22, v41, 180, d1 / 2 + 20, 1, height, arrowsize, exline, "L=" + oal, "", "");


                }
                if (bbxz == "圆柱销快换柄")
                {
                    double L1 = 0;
                    double l1 = 0;
                    double l2 = 0;
                    double l3 = 0;
                    double d3 = 0;
                    double c = 0;
                    double h = 0;
                    if (d2 == 22)
                    {
                        L1 = 42;
                        l1 = 14;
                        l2 = 10.5;
                        l3 = 22.5;
                        d3 = 20;
                        c = 7.5;
                        h = 19;
                    }
                    if (d2 == 40)
                    {
                        L1 = 55;
                        l1 = 22;
                        l2 = 15.5;
                        l3 = 30.5;
                        d3 = 38;
                        c = 13;
                        h = 35;
                    }
                    Vector2 v33 = new Vector2(v3.X + d1 + l, v3.Y + d2 * 5.89 / 14.2);
                    Vector2 v35 = new Vector2(v33.X, v33.Y * -1);
                    Vector2 v34 = new Vector2(v33.X + oal - l - L1, v33.Y);
                    Vector2 v36 = new Vector2(v34.X, v35.Y);
                    Vector2 v37 = new Vector2(v34.X, v3.Y + d2 / 2);
                    Vector2 v38 = new Vector2(v37.X + l2 - (d2 - d3) / 2, v37.Y);
                    Vector2 v39 = new Vector2(v37.X + l2, v3.Y + d3 / 2);
                    Vector2 v40 = new Vector2(v39.X + (L1 - l2 - l3), v39.Y);
                    Vector2 v41 = new Vector2(v40.X + (d2 - d3) / 2, v38.Y);
                    Vector2 v42 = new Vector2(v34.X + L1 - L1 * 1.85 / 40.09, v41.Y);
                    Vector2 v43 = new Vector2(v34.X + L1, v3.Y + d2 * 4.1 / 14.2);
                    Vector2 v44 = new Vector2(v43.X, v42.Y - h);
                    Vector2 v45 = new Vector2(v42.X, v44.Y);
                    Vector2 v46 = new Vector2(v44.X - l3 * 13.28 / 24.14, v45.Y);
                    Vector2 v47 = new Vector2(v44.X - l1, v41.Y * -1);
                    Vector2 v48 = new Vector2(v41.X, v47.Y);
                    Vector2 v49 = new Vector2(v40.X, v40.Y * -1);
                    Vector2 v50 = new Vector2(v39.X, v39.Y * -1);
                    Vector2 v51 = new Vector2(v38.X, v38.Y * -1);
                    Vector2 v52 = new Vector2(v37.X, v37.Y * -1);
                    Vector2 v53 = new Vector2(v44.X - c, v3.Y);
                    Vector2 v56 = new Vector2(v53.X - l1 * 3.58 / 18, v45.Y);
                    Vector2 v55 = new Vector2(v56.X, v3.Y);
                    Vector2 v54 = new Vector2(v53.X + l1 * 3.58 / 18, v55.Y);
                    Vector2 v61 = new Vector2(v54.X, v45.Y);
                    Vector2 v57 = new Vector2(v53.X - l1 * 2.24 / 18, v45.Y);
                    Vector2 v58 = new Vector2(v57.X, v3.Y);
                    Vector2 v59 = new Vector2(v53.X + l1 * 2.24 / 18, v53.Y);
                    Vector2 v60 = new Vector2(v59.X, v45.Y);

                    LwPolyline line7 = new LwPolyline();
                    line7.Vertexes.Add(new LwPolylineVertex(v38));
                    line7.Vertexes.Add(new LwPolylineVertex(v51));
                    line7.Vertexes.Add(new LwPolylineVertex(v52));
                    line7.Vertexes.Add(new LwPolylineVertex(v37));
                    line7.Vertexes.Add(new LwPolylineVertex(v38));
                    line7.Vertexes.Add(new LwPolylineVertex(v39));
                    line7.Vertexes.Add(new LwPolylineVertex(v50));
                    line7.Vertexes.Add(new LwPolylineVertex(v51));
                    line7.Vertexes.Add(new LwPolylineVertex(v50));
                    line7.Vertexes.Add(new LwPolylineVertex(v49));
                    line7.Vertexes.Add(new LwPolylineVertex(v40));
                    line7.Vertexes.Add(new LwPolylineVertex(v39));
                    line7.Vertexes.Add(new LwPolylineVertex(v40));
                    line7.Vertexes.Add(new LwPolylineVertex(v41));
                    line7.Vertexes.Add(new LwPolylineVertex(v48));
                    line7.Vertexes.Add(new LwPolylineVertex(v49));
                    fun.PolyFill(dxf, line7, 0.2, contour);

                    LwPolyline line9 = new LwPolyline();
                    line9.Vertexes.Add(new LwPolylineVertex(v33));
                    line9.Vertexes.Add(new LwPolylineVertex(v35));
                    line9.Vertexes.Add(new LwPolylineVertex(v36));
                    line9.Vertexes.Add(new LwPolylineVertex(v34));
                    line9.Vertexes.Add(new LwPolylineVertex(v33));
                    line9.Vertexes.Add(new LwPolylineVertex(v18));
                    line9.Vertexes.Add(new LwPolylineVertex(v19));
                    line9.Vertexes.Add(new LwPolylineVertex(v35));
                    fun.PolyFill(dxf, line9, 0.2, contour);

                    LwPolyline line8 = new LwPolyline();
                    line8.Vertexes.Add(new LwPolylineVertex(v48));
                    line8.Vertexes.Add(new LwPolylineVertex(v47));
                    line8.Vertexes.Add(new LwPolylineVertex(v46));
                    line8.Vertexes.Add(new LwPolylineVertex(v44));
                    line8.Vertexes.Add(new LwPolylineVertex(v43));
                    line8.Vertexes.Add(new LwPolylineVertex(v42));
                    line8.Vertexes.Add(new LwPolylineVertex(v45));
                    line8.Vertexes.Add(new LwPolylineVertex(v42));
                    line8.Vertexes.Add(new LwPolylineVertex(v41));
                    line8.Vertexes[1].Bulge = Math.Tan(-50 * pi / 180 / 4);
                    fun.PolyFill(dxf, line8, 0.2, contour);

                    LwPolyline line10 = new LwPolyline();
                    line10.Vertexes.Add(new LwPolylineVertex(v56));
                    line10.Vertexes.Add(new LwPolylineVertex(v55));
                    line10.Vertexes.Add(new LwPolylineVertex(v54));
                    line10.Vertexes.Add(new LwPolylineVertex(v61));
                    line10.Vertexes.Add(new LwPolylineVertex(v60));
                    line10.Vertexes.Add(new LwPolylineVertex(v59));
                    line10.Vertexes.Add(new LwPolylineVertex(v58));
                    line10.Vertexes.Add(new LwPolylineVertex(v57));
                    line10.Vertexes[1].Bulge = Math.Tan(-180 * pi / 180 / 4);
                    line10.Vertexes[5].Bulge = Math.Tan(180 * pi / 180 / 4);
                    fun.PolyFill(dxf, line10, 0.2, contour);

                    //标注

                    double height = 5;
                    double arrowsize = 1;
                    double exline = 2;

                    fun.dimrot1(dxf, v5, v8, 90, d1 / 2 + 10, 1, height, arrowsize, exline, "d1=" + d1, "", "");

                    fun.dimrot1(dxf, v28, v22, 90, d1 / 2 + 20, 1, height, arrowsize, exline, "d=" + d, "", "");

                    fun.dimrot1(dxf, v22, v35, 180, d1 / 2 + 10, 1, height, arrowsize, exline, "l=" + l, "", "");

                    fun.dimrot1(dxf, v22, v41, 180, d1 / 2 + 20, 1, height, arrowsize, exline, "L=" + oal, "", "");

                    fun.dimrot1(dxf, v42, v47, -90, l3 + 10, 1, height, arrowsize, exline, "d2=" + d2, "", "");


                }

            }
            //图框
            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            Vector2 p0 = new Vector2(0, 0);

            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - 10 * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }


            //定义格式，路径导出
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);


        }

    }
}